Skip to content

noUncheckedIndexedAccess gives unexpected behavior for string.split #41638

@sla100

Description

@sla100

TypeScript Version: 4.1.2

Search Terms:
4.1.2 split

Code

const [a] = 'a:b'.split(':');

Expected behavior:
typeof a should be string

string.split ALWAYS return string at first position

Actual behavior:
tyeof a is string|undefined

Metadata

Metadata

Assignees

No one assigned

    Labels

    Won't FixThe severity and priority of this issue do not warrant the time or complexity needed to fix it

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions