Skip to content

TypeScript shouldn't assume {[name: string]: NonUndefinedType} has no undefined properties #23817

@KSXGitHub

Description

@KSXGitHub

TypeScript Version: 2.8.3

Search Terms: object type undefined

Code

interface Foo {
    [_: string]: number
}

const foo: Foo = {}

// foo.abc is undefined, but TypeScript allows this
foo.abc.toString()

Expected behavior:

Object is possibly undefined

Actual behavior:

TypeScript allows it

Playground Link: link

Related Issues:

Metadata

Metadata

Assignees

No one assigned

    Labels

    DuplicateAn existing issue was already created

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions