[英]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.我们在vscode中创建一个ts文件,故意写错类型后向我们报错。 Is the type checked at this time?
这个时候检查类型了吗? We haven't done anything yet.
我们还没有做任何事情。
So when did typescript start type checking?那么typescript是什么时候开始类型检查的呢?
Is TypeScript also type checked at compile time?
TypeScript 是否也在编译时进行了类型检查?
Yes.是的。 In fact, other than a very small aspect related to
enum
s, TypeScript doesn't exist at runtime at all.事实上,除了与
enum
s 相关的一个非常小的方面,TypeScript 在运行时根本不存在。 TypeScript compiles to JavaScript, which is a dynamically-typed language. TypeScript 编译为 JavaScript,这是一种动态类型语言。
We haven't done anything yet.
我们还没有做任何事情。 ... So when did typescript start type checking?
... 那么 typescript 是什么时候开始类型检查的呢?
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.与许多 IDE 一样,VSCode 将在您进行类型检查代码和报告问题时在幕后运行 TypeScript,然后 IDE 会向您报告这些问题。 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).
IDE 在“无发射”模式下运行 TypeScript(它不会产生通常的 JavaScript 输出)所以它只是进行语法检查(因为它必须完成它的工作)和类型检查(它的主要工作)。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.