-
Notifications
You must be signed in to change notification settings - Fork 13k
Open
Labels
Possible ImprovementThe current behavior isn't wrong, but it's possible to see that it might be better in some casesThe current behavior isn't wrong, but it's possible to see that it might be better in some cases
Milestone
Description
Bug Report
π Search Terms
cannot be used as an index type
π Version & Regression Information
- This changed between versions 4.9.5 and 5.0.4
β― Playground Link
Playground link with relevant code
π» Code
interface Dict {
foo: 1
bar: 1
}
type A = Dict['foo'] // works
type F = 'foo'
type B = Dict[F] // works
type FF = 'foo' extends ('foo' | 'bar') ? 'foo' : never // in theory, FF === F
type C = Dict[FF] // not working, Type '"foo"' cannot be used as an index type.(2538)
π Actual behavior
type C
throws error
π Expected behavior
no error
fatcerberus
Metadata
Metadata
Assignees
Labels
Possible ImprovementThe current behavior isn't wrong, but it's possible to see that it might be better in some casesThe current behavior isn't wrong, but it's possible to see that it might be better in some cases