mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-21 13:14:43 -06:00
Fix crash getting error for type alias index signature without a type
This commit is contained in:
parent
6608349ea2
commit
956436853e
@ -31005,7 +31005,7 @@ namespace ts {
|
||||
Diagnostics.An_index_signature_parameter_type_cannot_be_a_type_alias_Consider_writing_0_Colon_1_Colon_2_instead,
|
||||
getTextOfNode(parameter.name),
|
||||
typeToString(type),
|
||||
typeToString(getTypeFromTypeNode(node.type!)));
|
||||
typeToString(node.type ? getTypeFromTypeNode(node.type) : anyType));
|
||||
}
|
||||
|
||||
if (type.flags & TypeFlags.Union && allTypesAssignableToKind(type, TypeFlags.StringLiteral, /*strict*/ true)) {
|
||||
|
||||
@ -9,9 +9,10 @@ tests/cases/compiler/indexerConstraints2.ts(58,6): error TS1023: An index signat
|
||||
tests/cases/compiler/indexerConstraints2.ts(64,6): error TS1023: An index signature parameter type must be 'string' or 'number'.
|
||||
tests/cases/compiler/indexerConstraints2.ts(70,6): error TS1023: An index signature parameter type must be 'string' or 'number'.
|
||||
tests/cases/compiler/indexerConstraints2.ts(74,6): error TS1337: An index signature parameter type cannot be a union type. Consider using a mapped object type instead.
|
||||
tests/cases/compiler/indexerConstraints2.ts(79,6): error TS1336: An index signature parameter type cannot be a type alias. Consider writing '[key: string]: any' instead.
|
||||
|
||||
|
||||
==== tests/cases/compiler/indexerConstraints2.ts (11 errors) ====
|
||||
==== tests/cases/compiler/indexerConstraints2.ts (12 errors) ====
|
||||
class A { a: number; }
|
||||
class B extends A { b: number; }
|
||||
|
||||
@ -108,4 +109,12 @@ tests/cases/compiler/indexerConstraints2.ts(74,6): error TS1337: An index signat
|
||||
[u: "foo" | "bar"]: A;
|
||||
~
|
||||
!!! error TS1337: An index signature parameter type cannot be a union type. Consider using a mapped object type instead.
|
||||
}
|
||||
}
|
||||
|
||||
type Key = string;
|
||||
interface T {
|
||||
[key: Key]
|
||||
~~~
|
||||
!!! error TS1336: An index signature parameter type cannot be a type alias. Consider writing '[key: string]: any' instead.
|
||||
}
|
||||
|
||||
@ -73,7 +73,13 @@ interface R {
|
||||
|
||||
interface S {
|
||||
[u: "foo" | "bar"]: A;
|
||||
}
|
||||
}
|
||||
|
||||
type Key = string;
|
||||
interface T {
|
||||
[key: Key]
|
||||
}
|
||||
|
||||
|
||||
//// [indexerConstraints2.js]
|
||||
var __extends = (this && this.__extends) || (function () {
|
||||
|
||||
@ -155,3 +155,15 @@ interface S {
|
||||
>u : Symbol(u, Decl(indexerConstraints2.ts, 73, 5))
|
||||
>A : Symbol(A, Decl(indexerConstraints2.ts, 0, 0))
|
||||
}
|
||||
|
||||
type Key = string;
|
||||
>Key : Symbol(Key, Decl(indexerConstraints2.ts, 74, 1))
|
||||
|
||||
interface T {
|
||||
>T : Symbol(T, Decl(indexerConstraints2.ts, 76, 18))
|
||||
|
||||
[key: Key]
|
||||
>key : Symbol(key, Decl(indexerConstraints2.ts, 78, 5))
|
||||
>Key : Symbol(Key, Decl(indexerConstraints2.ts, 74, 1))
|
||||
}
|
||||
|
||||
|
||||
@ -118,3 +118,12 @@ interface S {
|
||||
[u: "foo" | "bar"]: A;
|
||||
>u : IndexableUnion
|
||||
}
|
||||
|
||||
type Key = string;
|
||||
>Key : string
|
||||
|
||||
interface T {
|
||||
[key: Key]
|
||||
>key : string
|
||||
}
|
||||
|
||||
|
||||
@ -72,4 +72,9 @@ interface R {
|
||||
|
||||
interface S {
|
||||
[u: "foo" | "bar"]: A;
|
||||
}
|
||||
}
|
||||
|
||||
type Key = string;
|
||||
interface T {
|
||||
[key: Key]
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user