We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
“语言简介(intro.md)”中。 “上面示例中,例一的报错是因为变量一旦赋值了,就不允许再改变类型”,这段描述可能有问题。
变量的类型确定,应该是在变量声明的时候,而不是赋值的时候。
// 这段代码可以通过编译,因为在第一行 c 已经被推断为 any 类型(这只是我的猜测) let c; console.log(typeof c); c = 1; console.log(typeof c); c = '1'; console.log(typeof c);
The text was updated successfully, but these errors were encountered:
上面代码不报错,早就被诟病了,变量声明没有给出类型。
[1] microsoft/TypeScript#30899
[2] https://stackoverflow.com/questions/73440042/typescript-prevent-inferring-types-except-at-variable-declaration
Sorry, something went wrong.
docs(any): fix #8
4d13768
这种确实有点尴尬,其它语言类型推断都是一定要赋值的
No branches or pull requests
“语言简介(intro.md)”中。
“上面示例中,例一的报错是因为变量一旦赋值了,就不允许再改变类型”,这段描述可能有问题。
变量的类型确定,应该是在变量声明的时候,而不是赋值的时候。
The text was updated successfully, but these errors were encountered: