[Typescript] Unknow and any Types

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

 

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

 

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

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

posted @ 2022-07-19 02:27  Zhentiw  阅读(33)  评论(0)    收藏  举报