Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
DetachHead opened this issue Jun 25, 2022 · 0 comments Β· Fixed by #49696
Assignees
Labels
Fix Available A PR has been opened for this issue

Comments

@DetachHead
Copy link
Contributor

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

type Foo = { [key: string]: unknown }
type NullableFoo = Foo | undefined

type Bar<T extends NullableFoo> = NonNullable<T>[string] //error on 4.8, no error on 4.7

type Baz<T extends Foo> = NonNullable<T>[string] // no error
type Qux = NonNullable<NullableFoo>[string] // no error

πŸ™ Actual behavior

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

πŸ™‚ Expected behavior

no error

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Fix Available A PR has been opened for this issue
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants