概念: 类型 Widening
概念检查 中等
题目
什么是 类型 widening in TypeScript?
提示
Think about let vs const — why does let x = 5 give number but const x = 5 gives 5?
解释
Type widening occurs when TypeScript generalizes a literal type to its base type. For let x = 5, x is widened to number because let variables can be reassigned. For const x = 5, x stays as the literal type 5 because const cannot change. You can prevent widening with as const.
查阅不认识的术语
新手友好的术语表用大白话解释编程术语——变量、函数、DOM、Promise 等等。
解读错误信息
用大白话解释常见错误——什么意思、为什么发生、如何修复。
动手做项目
通过引导式项目应用所学,含起始代码与解决方案。