Typescript: Why can a string of type any be assigned to type number?

Created on 10 May 2019  ·  1Comment  ·  Source: microsoft/TypeScript

let str: any= 'str' let num: number = str //ok

Question

Most helpful comment

Because this is the reason of the type any: be assignable from and to any other type. See it on basic types. Recommendation, read the FAQs.

Better ask questions to stackoverflow.

>All comments

Because this is the reason of the type any: be assignable from and to any other type. See it on basic types. Recommendation, read the FAQs.

Better ask questions to stackoverflow.

Was this page helpful?
0 / 5 - 0 ratings