0e905be42b
* Switch index signature storage to 'indexInfos: IndexInfo[]' property * Accept new baselines * Remove another usage of IndexKind enum * Update getIndexedAccessType and resolveMappedTypeMembers * Accept new baselines * Update grammar checking for index signatures * Accept new baselines * Consider all index signatures in mapped types and union types * Accept new baselines * Update getIndexType * Accept new baselines * Intersect multiple applicable index signatures * Use getApplicableIndexInfo instead of hardwired string/number handling * Update index signature relationship checking * Report type for which index signature is missing * Report type for which index signature is missing * Accept new baselines * Make 'number' index signatures consistently apply to numeric strings * Accept new baselines * Update fourslash test * Revise index constraint checking * Accept new baselines * Update error messages * Accept new baselines * Update type inference from index signatures * Update isKnownProperty * Update contextual typing based on index signatures * Accept new baselines * Support union types in index signature declarations * Accept new baselines * Check duplicate index signatures / remove redundant template literals from unions with string * Accept new baselines * Include key type in diagnostic / check symbol-named properties * Accept new baselines * Minor fix * Add tests * Accept new baselines * Add optimized findApplicableIndexInfoForName * Accept new baselines * Another place we don't need to obtain literal type for property name * Accept new baselines * Don't create literal types that are going to be discarded * Individual maps for string, number, bigint, and enum literal types * Remove ineffective optimizations * Accept new baselines * Permit intersections as key types in index signatures * Index expression in element access is template literal context * Add tests * Accept new baselines * Symbol index signatures from object literals with computed symbol properties * Accept new baselines * Add more tests * Accept new baselines * Implement Go To Definition for all applicable index signatures * Add fourslash test * Accept new API baselines
111 lines
5.8 KiB
Plaintext
111 lines
5.8 KiB
Plaintext
tests/cases/compiler/propertiesAndIndexers.ts(16,5): error TS2411: Property '1' of type 'Z' is not assignable to 'number' index type 'string'.
|
|
tests/cases/compiler/propertiesAndIndexers.ts(18,5): error TS2411: Property '3' of type 'boolean' is not assignable to 'number' index type 'string'.
|
|
tests/cases/compiler/propertiesAndIndexers.ts(19,5): error TS2411: Property '6' of type '() => string' is not assignable to 'number' index type 'string'.
|
|
tests/cases/compiler/propertiesAndIndexers.ts(23,5): error TS2411: Property '4' of type 'boolean' is not assignable to 'number' index type 'string'.
|
|
tests/cases/compiler/propertiesAndIndexers.ts(28,5): error TS2411: Property '1' of type 'Z' is not assignable to 'string' index type 'number'.
|
|
tests/cases/compiler/propertiesAndIndexers.ts(28,5): error TS2411: Property 'a' of type 'Y' is not assignable to 'string' index type 'number'.
|
|
tests/cases/compiler/propertiesAndIndexers.ts(28,5): error TS2411: Property 'b' of type 'X' is not assignable to 'string' index type 'number'.
|
|
tests/cases/compiler/propertiesAndIndexers.ts(29,5): error TS2411: Property 'c' of type 'boolean' is not assignable to 'string' index type 'number'.
|
|
tests/cases/compiler/propertiesAndIndexers.ts(30,5): error TS2411: Property '3' of type 'boolean' is not assignable to 'string' index type 'number'.
|
|
tests/cases/compiler/propertiesAndIndexers.ts(33,11): error TS2411: Property '4' of type 'boolean' is not assignable to 'string' index type 'number'.
|
|
tests/cases/compiler/propertiesAndIndexers.ts(33,11): error TS2411: Property '5' of type 'string' is not assignable to 'string' index type 'number'.
|
|
tests/cases/compiler/propertiesAndIndexers.ts(33,11): error TS2411: Property '6' of type '() => string' is not assignable to 'string' index type 'number'.
|
|
tests/cases/compiler/propertiesAndIndexers.ts(33,11): error TS2413: 'number' index type 'string' is not assignable to 'string' index type 'number'.
|
|
tests/cases/compiler/propertiesAndIndexers.ts(34,5): error TS2411: Property '2' of type 'Z' is not assignable to 'number' index type 'string'.
|
|
tests/cases/compiler/propertiesAndIndexers.ts(34,5): error TS2411: Property '2' of type 'Z' is not assignable to 'string' index type 'number'.
|
|
tests/cases/compiler/propertiesAndIndexers.ts(35,5): error TS2411: Property 'Infinity' of type 'number' is not assignable to 'number' index type 'string'.
|
|
tests/cases/compiler/propertiesAndIndexers.ts(36,5): error TS2411: Property 'zoo' of type 'string' is not assignable to 'string' index type 'number'.
|
|
tests/cases/compiler/propertiesAndIndexers.ts(44,5): error TS2411: Property 't' of type 'number' is not assignable to 'string' index type 'string'.
|
|
tests/cases/compiler/propertiesAndIndexers.ts(50,5): error TS2411: Property '3' of type 'boolean' is not assignable to 'number' index type 'string'.
|
|
|
|
|
|
==== tests/cases/compiler/propertiesAndIndexers.ts (19 errors) ====
|
|
interface X { }
|
|
interface Y {
|
|
n: number;
|
|
}
|
|
interface Z {
|
|
s: string;
|
|
}
|
|
|
|
interface A {
|
|
a: Y;
|
|
b: X;
|
|
1: Z;
|
|
}
|
|
|
|
interface B extends A {
|
|
[n: number]: string;
|
|
~~~~~~~~~~~~~~~~~~~~
|
|
!!! error TS2411: Property '1' of type 'Z' is not assignable to 'number' index type 'string'.
|
|
c: boolean;
|
|
3: boolean;
|
|
~
|
|
!!! error TS2411: Property '3' of type 'boolean' is not assignable to 'number' index type 'string'.
|
|
6(): string;
|
|
~~~~~~~~~~~~
|
|
!!! error TS2411: Property '6' of type '() => string' is not assignable to 'number' index type 'string'.
|
|
}
|
|
|
|
interface B {
|
|
4: boolean;
|
|
~
|
|
!!! error TS2411: Property '4' of type 'boolean' is not assignable to 'number' index type 'string'.
|
|
5: string;
|
|
}
|
|
|
|
interface C extends A {
|
|
[s: string]: number;
|
|
~~~~~~~~~~~~~~~~~~~~
|
|
!!! error TS2411: Property '1' of type 'Z' is not assignable to 'string' index type 'number'.
|
|
~~~~~~~~~~~~~~~~~~~~
|
|
!!! error TS2411: Property 'a' of type 'Y' is not assignable to 'string' index type 'number'.
|
|
~~~~~~~~~~~~~~~~~~~~
|
|
!!! error TS2411: Property 'b' of type 'X' is not assignable to 'string' index type 'number'.
|
|
c: boolean;
|
|
~
|
|
!!! error TS2411: Property 'c' of type 'boolean' is not assignable to 'string' index type 'number'.
|
|
3: boolean;
|
|
~
|
|
!!! error TS2411: Property '3' of type 'boolean' is not assignable to 'string' index type 'number'.
|
|
}
|
|
|
|
interface D extends B, C {
|
|
~
|
|
!!! error TS2411: Property '4' of type 'boolean' is not assignable to 'string' index type 'number'.
|
|
~
|
|
!!! error TS2411: Property '5' of type 'string' is not assignable to 'string' index type 'number'.
|
|
~
|
|
!!! error TS2411: Property '6' of type '() => string' is not assignable to 'string' index type 'number'.
|
|
~
|
|
!!! error TS2413: 'number' index type 'string' is not assignable to 'string' index type 'number'.
|
|
2: Z;
|
|
~
|
|
!!! error TS2411: Property '2' of type 'Z' is not assignable to 'number' index type 'string'.
|
|
~
|
|
!!! error TS2411: Property '2' of type 'Z' is not assignable to 'string' index type 'number'.
|
|
Infinity: number;
|
|
~~~~~~~~
|
|
!!! error TS2411: Property 'Infinity' of type 'number' is not assignable to 'number' index type 'string'.
|
|
zoo: string;
|
|
~~~
|
|
!!! error TS2411: Property 'zoo' of type 'string' is not assignable to 'string' index type 'number'.
|
|
}
|
|
|
|
class P {
|
|
[n: string]: string
|
|
}
|
|
|
|
class Q extends P {
|
|
t: number;
|
|
~
|
|
!!! error TS2411: Property 't' of type 'number' is not assignable to 'string' index type 'string'.
|
|
}
|
|
|
|
var c: {
|
|
[n: number]: string;
|
|
c: boolean;
|
|
3: boolean;
|
|
~
|
|
!!! error TS2411: Property '3' of type 'boolean' is not assignable to 'number' index type 'string'.
|
|
}; |