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?
CodePudding user response:
Is TypeScript also type checked at compile time?
Yes. In fact, other than a very small aspect related to enum
s, 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).