Skip to content

Type { toUpperCase: () => string; } | undefined should be assignable the value '' #84

@sstchur

Description

@sstchur

The Type { toUpperCase: () => string; } | undefined should be assignable the value '', but when I get a type like the aforementioned type using checker.getTypeAtLocation(node) and then use it like isAssignableToValue(type, '') it returns false.

You can clearly see that it should work by just trying it out in the TS playground:

let x: { toUpperCase: () => string; } | undefined = '';

TS has no problem with the above code b/c '' "looks like" a string (since all strings have .toUpperCase() which returns a string.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions