Skip to content

strictNullChecks: undefined is not assignable to type script #16902

@alan-agius4

Description

@alan-agius4

TypeScript Version: 2.4.1

Code

if (process.env.npm_config_argv !== undefined) {
const x = JSON.parse(process.env.npm_config_argv);
....
}

Expected behavior:
no errors as i am already doing a check

Actual behavior:
error TS2345: Argument of type 'string | undefined' is not assignable to parameter of type 'string'.
Type 'undefined' is not assignable to type 'string'.

Metadata

Metadata

Assignees

No one assigned

    Labels

    DuplicateAn existing issue was already created

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions