![[捂脸]](http://lf-web-assets.juejin.cn/obj/juejin-web/xitu_juejin_web/img/jj_emoji_28.8981538.png)
@每日英语1
Understand the Relationship between Typescript and Javascript
- Typescript is a superset of Javascript. In other words, all Javascript programs are already Typescript programs. Typescript has some syntax of its own, so Typescript programs are not, in general, valid Javascript programs.
- Typescript adds a type system that models Javascript's runtime behavior and tries to spot code which will throw exceptions at runtime. But you shouldn't expect it to flag every exception. It is possible for code to pass the type checker but still throw at runtime.
- While Typescript's type system largely models Javascript behavior, there are some constructs that Javascript allows but Typescript chooses to bar, such as calling functions with the wrong number of arguments. This is largely a matter of taste.
Understand the Relationship between Typescript and Javascript
- Typescript is a superset of Javascript. In other words, all Javascript programs are already Typescript programs. Typescript has some syntax of its own, so Typescript programs are not, in general, valid Javascript programs.
- Typescript adds a type system that models Javascript's runtime behavior and tries to spot code which will throw exceptions at runtime. But you shouldn't expect it to flag every exception. It is possible for code to pass the type checker but still throw at runtime.
- While Typescript's type system largely models Javascript behavior, there are some constructs that Javascript allows but Typescript chooses to bar, such as calling functions with the wrong number of arguments. This is largely a matter of taste.
展开
评论
点赞