by seivan · 10y ago · 0 comments
Thank you! How well would this work with an editor and typescript plugins? Say the amazing typescript-atom, I would guess the editor would crap its pants, no?
declare var somelib: any;
Done. Now the compiler and everything else will know that there's a global variable called `somelib` that does not have a specific type, and no matter how you use that variable, it's ok, you know what you're doing.Editors have no problem with it. They will simply see it as an "any" var. Completely compatible.
I wrote quite a bit of TS and this was how I used most obscure libraries. I can't be arsed to keep those stupid .d.ts files up to date and I trust the API docs. It's my own code I wanted to vet. Works like a charm.
Judicious use of declare var any, and ignoring compiler errors, is what really makes TS reality-compatible.