Commit b8e0ded
committed
1. `T[K]` now correctly produces `number` when
`K extends string, T extends Record<K, number>`.
2. `T[K]` no longer allows any type to be assigned to it when
`T extends object, K extends keyof T`.
Previously both of these cases failed in
getConstraintOfIndexedAccessType because both bases followed `K`'s base
constraint to `string` and then incorrectly produced `any` for types
(like `object`) with no string index signature. In (1), this produced an
error in checkBinaryLikeExpression`. In (2), this failed to produce an
error in `checkTypeRelatedTo`.
1 parent 76fb654 commit b8e0ded
2 files changed
Lines changed: 12 additions & 5 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5912 | 5912 | | |
5913 | 5913 | | |
5914 | 5914 | | |
5915 | | - | |
| 5915 | + | |
| 5916 | + | |
| 5917 | + | |
| 5918 | + | |
| 5919 | + | |
| 5920 | + | |
| 5921 | + | |
5916 | 5922 | | |
5917 | 5923 | | |
5918 | 5924 | | |
| |||
5962 | 5968 | | |
5963 | 5969 | | |
5964 | 5970 | | |
5965 | | - | |
5966 | | - | |
| 5971 | + | |
| 5972 | + | |
| 5973 | + | |
5967 | 5974 | | |
5968 | 5975 | | |
5969 | 5976 | | |
| |||
9290 | 9297 | | |
9291 | 9298 | | |
9292 | 9299 | | |
9293 | | - | |
| 9300 | + | |
9294 | 9301 | | |
9295 | 9302 | | |
9296 | 9303 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
718 | 718 | | |
719 | 719 | | |
720 | 720 | | |
721 | | - | |
| 721 | + | |
722 | 722 | | |
723 | 723 | | |
724 | 724 | | |
| |||
0 commit comments