TypeScript is a tradeoff.

"I use typescript when I feel like having hours of migraines using 3rd party libraries and making sure I don't have a single space or comma out of place! Works like a charm! Get a headache 10/10 times."

-somebody on Reddit

TypeScript can do wonders for your code editor's ability to help you with auto-completions, it can enforce contracts between different parts of your code base in the way documentation never could, and it can help a large team move faster.

typescript errors

It can also drive you to the point of madness when dealing with its increasingly pedantic compiler, especially when dealing with third party libraries that have incomplete, incorrect or conflicting types.

In general, it's good to type as much as possible so you get the benefits TS offers. But how do you silence compiler warnings when it's not your code and the upstream library just isn't typed correctly?

You can add this to your codebase:

declare const annoyingLibrary: any;

And then, the TypeScript compiler will stop complaining about annoyingLibrary types.

Leave a Reply

Your email address will not be published. Required fields are marked *

1 reply