Skip to content

Object.keys(undefined) does not fail with strictNullChecks #17273

Closed
@stephtr

Description

@stephtr

TypeScript Version: 2.4.1

Code: Object.keys(undefined)
(Object.getOwnPropertyNames and similar have the same issue.)

Expected behavior:
With strictNullChecks enabled it should result in an error (same as running the code as JavaScript).

Actual behavior:
It compiles without errors.

Possible solution:
In lib.*.d.ts replace keys(o: any): string[]; by keys(o: {}): string[];

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugA bug in TypeScriptDomain: lib.d.tsThe issue relates to the different libraries shipped with TypeScriptFixedA PR has been merged for this issue

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions