The new baselines all look correct to me, but obviously a number of the tests need to be updated to reflect union types and the new behavior of best common type. This commit does not cover that.
148 lines
No EOL
7.3 KiB
Text
148 lines
No EOL
7.3 KiB
Text
tests/cases/conformance/types/objectTypeLiteral/indexSignatures/numericIndexerConstrainsPropertyDeclarations.ts(23,9): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
|
|
tests/cases/conformance/types/objectTypeLiteral/indexSignatures/numericIndexerConstrainsPropertyDeclarations.ts(26,9): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
|
|
tests/cases/conformance/types/objectTypeLiteral/indexSignatures/numericIndexerConstrainsPropertyDeclarations.ts(36,16): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
|
|
tests/cases/conformance/types/objectTypeLiteral/indexSignatures/numericIndexerConstrainsPropertyDeclarations.ts(90,9): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
|
|
tests/cases/conformance/types/objectTypeLiteral/indexSignatures/numericIndexerConstrainsPropertyDeclarations.ts(93,9): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
|
|
tests/cases/conformance/types/objectTypeLiteral/indexSignatures/numericIndexerConstrainsPropertyDeclarations.ts(18,5): error TS2412: Property '2.0' of type 'number' is not assignable to numeric index type 'string'.
|
|
tests/cases/conformance/types/objectTypeLiteral/indexSignatures/numericIndexerConstrainsPropertyDeclarations.ts(20,5): error TS2412: Property '"4.0"' of type 'number' is not assignable to numeric index type 'string'.
|
|
tests/cases/conformance/types/objectTypeLiteral/indexSignatures/numericIndexerConstrainsPropertyDeclarations.ts(21,5): error TS2412: Property '3.0' of type 'MyNumber' is not assignable to numeric index type 'string'.
|
|
tests/cases/conformance/types/objectTypeLiteral/indexSignatures/numericIndexerConstrainsPropertyDeclarations.ts(50,5): error TS2412: Property '2.0' of type 'number' is not assignable to numeric index type 'string'.
|
|
tests/cases/conformance/types/objectTypeLiteral/indexSignatures/numericIndexerConstrainsPropertyDeclarations.ts(55,5): error TS2412: Property '"4.0"' of type 'number' is not assignable to numeric index type 'string'.
|
|
tests/cases/conformance/types/objectTypeLiteral/indexSignatures/numericIndexerConstrainsPropertyDeclarations.ts(68,5): error TS2412: Property '2.0' of type 'number' is not assignable to numeric index type 'string'.
|
|
tests/cases/conformance/types/objectTypeLiteral/indexSignatures/numericIndexerConstrainsPropertyDeclarations.ts(73,5): error TS2412: Property '"4.0"' of type 'number' is not assignable to numeric index type 'string'.
|
|
tests/cases/conformance/types/objectTypeLiteral/indexSignatures/numericIndexerConstrainsPropertyDeclarations.ts(78,5): error TS2322: Type '{ [x: number]: string | number; 1.0: string; 2.0: number; a: string; b: number; c: () => void; "d": string; "e": number; "3.0": string; "4.0": number; f: unknown; X: string; foo: () => string; }' is not assignable to type '{ [x: number]: string; }':
|
|
Index signatures are incompatible:
|
|
Type 'string | number' is not assignable to type 'string':
|
|
Type 'number' is not assignable to type 'string'.
|
|
tests/cases/conformance/types/objectTypeLiteral/indexSignatures/numericIndexerConstrainsPropertyDeclarations.ts(88,9): error TS2304: Cannot find name 'Myn'.
|
|
|
|
|
|
==== tests/cases/conformance/types/objectTypeLiteral/indexSignatures/numericIndexerConstrainsPropertyDeclarations.ts (14 errors) ====
|
|
// String indexer types constrain the types of named properties in their containing type
|
|
|
|
interface MyNumber extends Number {
|
|
foo: number;
|
|
}
|
|
|
|
class C {
|
|
[x: number]: string;
|
|
|
|
constructor() { } // ok
|
|
|
|
a: string; // ok
|
|
b: number; // ok
|
|
c: () => {} // ok
|
|
"d": string; // ok
|
|
"e": number; // ok
|
|
1.0: string; // ok
|
|
2.0: number; // error
|
|
~~~~~~~~~~~~
|
|
!!! error TS2412: Property '2.0' of type 'number' is not assignable to numeric index type 'string'.
|
|
"3.0": string; // ok
|
|
"4.0": number; // error
|
|
~~~~~~~~~~~~~~
|
|
!!! error TS2412: Property '"4.0"' of type 'number' is not assignable to numeric index type 'string'.
|
|
3.0: MyNumber // error
|
|
~~~~~~~~~~~~~
|
|
!!! error TS2412: Property '3.0' of type 'MyNumber' is not assignable to numeric index type 'string'.
|
|
|
|
get X() { // ok
|
|
~
|
|
!!! error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
|
|
return '';
|
|
}
|
|
set X(v) { } // ok
|
|
~
|
|
!!! error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
|
|
|
|
foo() {
|
|
return '';
|
|
}
|
|
|
|
static sa: number; // ok
|
|
static sb: string; // ok
|
|
|
|
static foo() { } // ok
|
|
static get X() { // ok
|
|
~
|
|
!!! error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
|
|
return 1;
|
|
}
|
|
}
|
|
|
|
interface I {
|
|
[x: number]: string;
|
|
|
|
a: string; // ok
|
|
b: number; // ok
|
|
c: () => {} // ok
|
|
"d": string; // ok
|
|
"e": number; // ok
|
|
1.0: string; // ok
|
|
2.0: number; // error
|
|
~~~~~~~~~~~~
|
|
!!! error TS2412: Property '2.0' of type 'number' is not assignable to numeric index type 'string'.
|
|
(): string; // ok
|
|
(x): number // ok
|
|
foo(): string; // ok
|
|
"3.0": string; // ok
|
|
"4.0": number; // error
|
|
~~~~~~~~~~~~~~
|
|
!!! error TS2412: Property '"4.0"' of type 'number' is not assignable to numeric index type 'string'.
|
|
f: MyNumber; // error
|
|
}
|
|
|
|
var a: {
|
|
[x: number]: string;
|
|
|
|
a: string; // ok
|
|
b: number; // ok
|
|
c: () => {} // ok
|
|
"d": string; // ok
|
|
"e": number; // ok
|
|
1.0: string; // ok
|
|
2.0: number; // error
|
|
~~~~~~~~~~~~
|
|
!!! error TS2412: Property '2.0' of type 'number' is not assignable to numeric index type 'string'.
|
|
(): string; // ok
|
|
(x): number // ok
|
|
foo(): string; // ok
|
|
"3.0": string; // ok
|
|
"4.0": number; // error
|
|
~~~~~~~~~~~~~~
|
|
!!! error TS2412: Property '"4.0"' of type 'number' is not assignable to numeric index type 'string'.
|
|
f: MyNumber; // error
|
|
}
|
|
|
|
// error
|
|
var b: { [x: number]: string; } = {
|
|
~
|
|
!!! error TS2322: Type '{ [x: number]: string | number; 1.0: string; 2.0: number; a: string; b: number; c: () => void; "d": string; "e": number; "3.0": string; "4.0": number; f: unknown; X: string; foo: () => string; }' is not assignable to type '{ [x: number]: string; }':
|
|
!!! error TS2322: Index signatures are incompatible:
|
|
!!! error TS2322: Type 'string | number' is not assignable to type 'string':
|
|
!!! error TS2322: Type 'number' is not assignable to type 'string'.
|
|
a: '',
|
|
b: 1,
|
|
c: () => { },
|
|
"d": '',
|
|
"e": 1,
|
|
1.0: '',
|
|
2.0: 1,
|
|
"3.0": '',
|
|
"4.0": 1,
|
|
f: <Myn>null,
|
|
~~~
|
|
!!! error TS2304: Cannot find name 'Myn'.
|
|
|
|
get X() {
|
|
~
|
|
!!! error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
|
|
return '';
|
|
},
|
|
set X(v) { },
|
|
~
|
|
!!! error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
|
|
foo() {
|
|
return '';
|
|
}
|
|
} |