-
Notifications
You must be signed in to change notification settings - Fork 3.2k
New issue
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
精读《Typescript infer 关键字》 #346
Comments
另外类型收敛是指,TS 在类型推导时大部分情况是类型收敛的(收敛最类型安全),这也符合协变的规则( |
文中的例子 |
没毛病 补充:我说的没毛病是说确实是多余的 @zhangyu1818 |
请问你确定这个 T21 为 string & number 么????????? |
楼上说的代码我放ts playground的结果是never,确实让人有一些疑惑 |
number & string 的结果就是never,你可以用其它的例子来验证 |
@feikerwu 想了下结果确实是number & string,但没有类型同时是number和string又变成了never |
是多余的,已经修复啦,谢谢! |
我觉得应该是 一个值即为 string 又为 number 的不存在吧,string 交叉 number 这有个么,我没见过。。。。
| |
江鑫
|
|
***@***.***
|
签名由网易邮箱大师定制
在2021年08月26日 ***@***.***> 写道:
@feikerwu 想了下结果确实是number & string,但没有类型同时是number和string又变成了never
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub, or unsubscribe.
|
基础类型不会存在交叉的,一个值怎么可能即为 string 又为 number 呢,所以这里才是 never 永远不可能存在的值类型
| |
江鑫
|
|
***@***.***
|
签名由网易邮箱大师定制
在2021年08月26日 ***@***.***> 写道:
@feikerwu 想了下结果确实是number & string,但没有类型同时是number和string又变成了never
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub, or unsubscribe.
|
本周精读的文章是 conditional-infer。infer 这个关键字工作中比较少用到,但需要进行类型编程时却是必不可少的,本周我们一起学习一下吧。
精读《Typescript infer 关键字》
The text was updated successfully, but these errors were encountered: