5 ms·
In order to interopt, you're going to be using `any` a lot of places. You then have the illusion of sound types. You have all the extra work of sound types. But
by hajile 7y ago
In order to interopt, you're going to be using `any` a lot of places. You then have the illusion of sound types. You have all the extra work of sound types. But you do not have sound types and should not be relying on them.
- eatonphil 7y ago> In order to interopt, you're going to be using `any` a lot of places. This is not true. Types may be complex and out of laziness (which we do suffer from) there may be `any` types laying around. But you can set up eslint rules that forbid this and turn off implicit `any` at the TypeScript compiler level so you aren't bit by the defaults (which are not nice, for sure). We have very few `any`'s now in our code and aim to get rid of all of them.
- WorldMaker 7y agoThe new-ish `unknown` type is also very useful for interop work to force adding runtime checks where needed. Some of the Typescript defaults are slowly moving to `unknown` rather than `any` in the strictest compile modes.
- hajile 7y agoIf you turn off `any` on a gradually-typed codebase, everything will blow up because of the untyped parts. Gradual typing CANNOT be sound unless you dynamically typecheck everything (at which point you are just doing what JS devs do anyway).
- eatonphil 7y ago> If you turn off `any` on a gradually-typed codebase, everything will blow up because of the untyped parts. Again, that's not true. A JavaScript file's exports don't have `any` type. Any types during interop are inferred (maybe?) or require bindings. The use of `any` in bindings is your (sometimes valid) choice. > Gradual typing CANNOT be sound TypeScript isn't sound [0]. [0] https://github.com/Microsoft/TypeScript/issues/9825 https://github.com/Microsoft/TypeScript/issues/9825