我该如何修复该错误The left-hand side of a 'for...in' statement cannot use a type annotation.?未编译的相关代码是一个简单的 for...in 循环:
const roles = ['a', 'b', 'c'] as const
type Roles = typeof roles[number] // 'a' | 'b' | 'c'
const roles = {
'a': '...',
'b': '...',
'c': '...',
}
for (const role: Roles in roles) {
const isRole = roles.includes(roles)
}
Run Code Online (Sandbox Code Playgroud)
我知道不可能输入常量role,但如果我不这样做,则const isRole = roles.includes(roles)不会有效:Argument of type 'string' is not assignable to parameter of type '"a" | "b" …