严格模式
单选题 简单
题目
tsconfig 中 strict: true 启用什么?
提示
strict 启用 noImplicitAny、strictNullChecks、strictFunctionTypes 等。
解释
在 tsconfig.json 中设 "strict": true 同时启用所有严格类型检查选项:noImplicitAny(隐式 any 报错)、strictNullChecks(null/undefined 不可赋值给其他类型)、strictFunctionTypes(逆变函数参数检查)、strictBindCallApply、strictPropertyInitialization、noImplicitThis、alwaysStrict(输出 "use strict")、useUnknownInCatchVariables。严格模式在编译时捕获更多错误。强烈推荐所有新项目启用。可在保持 strict true 时退出个别检查。
相关资源
相关课程
- 严格模式
学习严格模式。
查阅不认识的术语
新手友好的术语表用大白话解释编程术语——变量、函数、DOM、Promise 等等。
解读错误信息
用大白话解释常见错误——什么意思、为什么发生、如何修复。
动手做项目
通过引导式项目应用所学,含起始代码与解决方案。