喜欢就关注我们吧!TypeScript 4.1 已正式发布。使用以下命令通过 npm 获取:npm install -D typescript新版本带来了不少新功能:新的检查标志、提升编辑器效率和速度。引入字符串模板类型function setVerticalAlignment(pos: "top" | "middle" | "bottom") {// ...}setVerticalAlignment("middel");// ~~~~~~~~// error: Argument of type '"middel"' is not assignable to// parameter of type '"top" | "middle" | "bottom"'.在映射类型中加入键值重映射 (Key Remapping)type Options = {[K in "noImplicitAny" | "strictNullChecks" | "strictFunctionTypes"]?: boolean};// same as// type Options = {// noImplicitAny?: boolean,// strictNullChecks?: boolean,// strictFunctionTypes?: boolean// };允许递归条件类型type ElementType =T extends ReadonlyArray ? ElementType : T;fu
………………………………