Skip to content

"cannot be used to index type" error when indexing NonNullable of a generic type in typescript 4.8Β #49681

Description

@DetachHead

Bug Report

πŸ”Ž Search Terms

4.8 nonnullable cannot be used to index type

πŸ•— Version & Regression Information

4.8.0-dev.20220624

  • This changed between versions 4.7.4 and 4.8-beta

⏯ Playground Link

Playground link with relevant code

πŸ’» Code

typeFoo={[key: string]: unknown}typeNullableFoo=Foo|undefinedtypeBar<TextendsNullableFoo>=NonNullable<T>[string]//error on 4.8, no error on 4.7typeBaz<TextendsFoo>=NonNullable<T>[string]// no errortypeQux=NonNullable<NullableFoo>[string]// no error

πŸ™ Actual behavior

Type 'string' cannot be used to index type 'NonNullable'.(2536)

πŸ™‚ Expected behavior

no error

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

Fix AvailableA PR has been opened for this issue

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions