在对象中,开发人员定义了如下代码常量:
medium: {
fontFamily: 'Roboto, "Helvetica Neue", Helvetica, Arial, sans-serif',
fontWeight: '500' as '500',
},
as关键字在做什么?
在对象中,开发人员定义了如下代码常量:
medium: {
fontFamily: 'Roboto, "Helvetica Neue", Helvetica, Arial, sans-serif',
fontWeight: '500' as '500',
},
as关键字在做什么?
referring to the answer in this question What does the "as" keyword do?
The
as
keyword is a Type Assertion in TypeScript which tells the compiler to consider the object as another type than the type the compiler infers the object to be.