mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-20 22:51:17 -05:00
Make T[never] = never instead of erroring or being any (#22787)
* Add tests showing existing behavior for indexing types with never. * Make T[never] = never instead of erroring or being any. And update the baselines for the tests for this change. * Add test case for indexing an expression with never showing existing behavior. * Make indexing an object with never expression result in never. And update baseline to reflect new behavior.
This commit is contained in:
committed by
Nathan Shively-Sanders
parent
dcbc478efa
commit
4fa96056ea
@@ -8151,6 +8151,9 @@ namespace ts {
|
||||
}
|
||||
return indexInfo.type;
|
||||
}
|
||||
if (indexType.flags & TypeFlags.Never) {
|
||||
return neverType;
|
||||
}
|
||||
if (accessExpression && !isConstEnumObjectType(objectType)) {
|
||||
if (noImplicitAny && !compilerOptions.suppressImplicitAnyIndexErrors) {
|
||||
if (getIndexTypeOfType(objectType, IndexKind.Number)) {
|
||||
|
||||
Reference in New Issue
Block a user