所以我对在typescript和NodeJS中的数组上使用findIndex ES6函数有一个问题。
我得到的错误信息是:
requestType.findIndex不是函数
这是我的代码:
let weatherStates:Array<string> = ['current', 'forecast'];
let requestType:string = 'current';
requestType.findIndex(weatherStates);
然后错误被抛出,我可以使用各种其他ES6功能,例如箭头功能等。
看起来填充的lib.core.d.ts中可以使用polyfill。
这是mytsconfig.json设置:
{
"compilerOptions": {
"module": "commonjs",
"target": "es6",
"sourceMap": true
},
"exclude": [
"node_modules",
"typings"
]
}
我是打字稿的新手,所以任何帮助都会非常感激!
答案 0 :(得分:0)
requestType
不是您示例中的数组。这是一个字符串。