![[捂脸]](http://lf-web-assets.juejin.cn/obj/juejin-web/xitu_juejin_web/img/jj_emoji_28.8981538.png)
@每日英语4
Get Comfortable with Structural Typing
- Understanding that Javascript is duck typed and Typescript uses structural typing to model this: values assignable to your interfaces might have properties beyond those explicitly listed in your type declaration. Types are not "sealed".
- Be aware that classes also follow structural typing rules. You may not have an instance of the class you expect.
- Use structural typing to facilitate unit testing.
Get Comfortable with Structural Typing
- Understanding that Javascript is duck typed and Typescript uses structural typing to model this: values assignable to your interfaces might have properties beyond those explicitly listed in your type declaration. Types are not "sealed".
- Be aware that classes also follow structural typing rules. You may not have an instance of the class you expect.
- Use structural typing to facilitate unit testing.
展开
评论
点赞