我收到以下内容的Typescript警告:
let d: { [key: string]: { [k: string]: boolean } | number[] } = {
blah: [],
};
d["blah"].push(2);
警告:
This expression is not callable.
Not all constituents of type 'boolean | ((...items: number[]) => number)'
are callable.
Type 'false' has no call signatures. (tsserver 2349)
代码有效,如果我控制台.log(d['blah']),我得到
[2]
。为什么我收到警告?如何更正(或忽略)?
我的tsconfig:
{
"compilerOptions": {
"target": "es2015",
"lib": ["dom", "dom.iterable", "esnext"],
"allowJs": true,
"skipLibCheck": true,
"strict": true,
"noEmit": true,
"esModuleInterop": true,
"module": "esnext",
"moduleResolution": "bundler",
"resolveJsonModule": true,
"isolatedModules": true,
"jsx": "preserve",
"incremental": true,
"plugins": [
{
"name": "next"
}
],
"paths": {
"@/*": ["./*"]
}
},
"include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", ".next/types/**/*.ts"],
"exclude": ["node_modules"]
}
我试着打印到控制台,代码有效,所以我很困惑为什么警告有效