3 ms·
Typescript also differentiates between checking and compiling as two different steps. So you could return something from a void function and use it and that wi
by langcss 2y ago
Typescript also differentiates between checking and compiling as two different steps.
So you could return something from a void function and use it and that will compile to JS and work but only the compile time type check would fail.
Highlighting that of course TS has no runtime checks of types.
- spoiler 2y agoYes, that's true of TypeScript in general. Code that fails type checking still gets emitted as JS. It's a bit annoying, but there's good reason for it. However, it can be controlled with compilerOptions.noEmitOnError (can be passed as a flag too). https://www.typescriptlang.org/tsconfig/#noEmitOnError https://www.typescriptlang.org/tsconfig/#noEmitOnError That being said, if using something like SWC or wrappers that's less useful, since they don't type check. TypeScript is great, but setting up projects that use it often come with some tradeoff (but I still think TS is worth it)