Typescript: Property 'isNaN' does not exist on type 'NumberConstructor'.

Created on 12 Apr 2017  路  4Comments  路  Source: microsoft/TypeScript

{
    "scripts": {
        "test": "tsc",
    },

    "devDependencies": {
        "typescript": "^2.2.2"
    }
}
{
    "compilerOptions": {
        "typeRoots": [
            "./node_modules/@types",
            "./index.d.ts"
        ],

        "lib": [
            "es2017",
            "dom"
        ],

        "target": "es2017",
        "module": "commonjs",
        "moduleResolution": "node",
        "noImplicitAny": false,

        "declaration": false,

        "allowSyntheticDefaultImports": false,
        "strictNullChecks": true,

        "emitDecoratorMetadata": true,
        "experimentalDecorators": true,
        "sourceMap": false
    },

    "exclude": [
        "./node_modules",
        "./cache"
    ]
}
if (!Number.isNaN(value)) {
    return Number.parseInt(value);
}
error TS2339: Property 'isNaN' does not exist on type 'NumberConstructor'.
error TS2339: Property 'parseInt' does not exist on type 'NumberConstructor'.

What's wrong?

Bug lib.d.ts Fixed

Most helpful comment

These are part of the es2015 library. make sure you have --lib es2015

All 4 comments

PRs welcomed. You can find more information about contributing lib.d.ts fixes at https://github.com/Microsoft/TypeScript/blob/master/CONTRIBUTING.md#contributing-libdts-fixes.

The same seems to apply for Number.isFinite()

error TS2339: Property 'isFinite' does not exist on type 'NumberConstructor'.

ts 2.5.3

The same applies for

Number.isInteger

These are part of the es2015 library. make sure you have --lib es2015

Was this page helpful?
0 / 5 - 0 ratings