[Typescript] Unknow and any Types


`any` type, you can assign any value for any type.

[Typescript] Unknow and any Types

 

For `unkown`, you can also assign any value to unkwon:

[Typescript] Unknow and any Types

 

But you cannot assign unkwon variable to another variable without checking the type, unknow force you to do the type checking before assign.

[Typescript] Unknow and any Types

if (typeof value14 === "string") {
  type value14: string = unknowValue // works
}

原创文章,作者:6024010,如若转载,请注明出处:https://blog.ytso.com/275329.html

(0)
上一篇 2022年7月19日
下一篇 2022年7月19日

相关推荐

发表回复

登录后才能评论