代码:
enum Ex0 {
One = '/home/node/',
Two = '/home/node/'
}
enum Ex1 {
One = path.normalize('~/'),
Two = path.normalize('~/')
}
错误:
application/libs/config.ts:19:11 - error TS2322: Type 'string' is not assignable to type 'Ex1'.
19 One = path.normalize('~/'),
~~~~~~~~~~~~~~~~~~~~
application/libs/config.ts:20:11 - error TS2322: Type 'string' is not assignable to type 'Ex1'.
20 Two = path.normalize('~/')
由于缺乏好的文档,我在理解Typescript枚举时遇到问题。谁能解释我在这里做错了什么。 path.normalize
返回类型string
。