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:
Kevin Donnelly
2018-03-27 09:45:25 -05:00
committed by Nathan Shively-Sanders
parent dcbc478efa
commit 4fa96056ea
5 changed files with 1028 additions and 0 deletions

View File

@@ -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)) {