我有这行代码使 Typescript 引发错误:
const owner:boolean = jsonFile.owners.includes("10");
Run Code Online (Sandbox Code Playgroud)
jsonFile 是我所做的
const owner:boolean = jsonFile.owners.includes("10");
Run Code Online (Sandbox Code Playgroud)
业主是空的string[]。
这是错误:
Argument of type 'string' is not assignable to parameter of type 'never'.
Run Code Online (Sandbox Code Playgroud)
我知道我需要为该数组分配类型,例如 make it never[]-> string[],我该怎么做?最好不要strictNullChecks在 tsconfig 下(解决这个问题)
| 归档时间: |
|
| 查看次数: |
703 次 |
| 最近记录: |