You can write definition files for libraries. A lot of libraries already have such files: https://github.com/borisyankov/DefinitelyTyped
If a particular library doesn't have one, you can write it yourself. In that case theres no need to model the entire library - you can only model the subset of functions / methods that you use.