'In general, static languages are type checked at compile time. Is typescript also type checked at compile time?

We create a TS file in vscode and report an error to us after deliberately writing a wrong type. Is the type checked at this time? We haven't done anything yet.

So when did typescript start type checking?



Solution 1:[1]

Is TypeScript also type checked at compile time?

Yes. In fact, other than a very small aspect related to enums, TypeScript doesn't exist at runtime at all. TypeScript compiles to JavaScript, which is a dynamically-typed language.

We haven't done anything yet. ... So when did typescript start type checking?

VSCode, like many IDEs, will run TypeScript under the covers as you're working to type-check the code and report issues, which the IDE then reports to you. The IDEs run TypeScript in "no emit" mode (it doesn't produce its usual JavaScript output) so it's just doing syntax checking (because it has to to do its job) and type checking (its primary job).

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1