Mick Feller Mick Feller - 9 months ago 229
Javascript Question

Typescript, NodeJS, ES6 - findIndex on array

So i have an issue with using findIndex ES6 function on an array in typescript and NodeJS.

The error message i'm getting is:

requestType.findIndex is not a function

this is my code:

let weatherStates:Array<string> = ['current', 'forecast'];
let requestType:string = 'current';

and then the error gets thrown, i'm able to use all sorts of other ES6 functionalities though, like the arrow functions etc.

it looks like that the polyfill is available in the lib.core.d.ts typing though.

Here is mytsconfig.json setup:

"compilerOptions": {
"module": "commonjs",
"target": "es6",
"sourceMap": true
"exclude": [

i'm fairly new with typescript so any help would be greatly appreciated!


requestType is not an array in your example. It is a string.