TypeScript/tests/baselines/reference/arityAndOrderCompatibility01.errors.txt
Anders Hejlsberg 5540364c12
Correct tuple relations in --strictOptionalProperties mode (#44568)
* Fix relations for optional elements in tuples with --strictOptionalProperties

* Accept new baselines

* Add regression test

* Address CR feedback
2021-06-13 12:53:13 -07:00

114 lines
7 KiB
Plaintext

tests/cases/conformance/types/tuple/arityAndOrderCompatibility01.ts(15,12): error TS2493: Tuple type '[string, number]' of length '2' has no element at index '2'.
tests/cases/conformance/types/tuple/arityAndOrderCompatibility01.ts(17,5): error TS2461: Type '{ 0: string; 1: number; length: 2; }' is not an array type.
tests/cases/conformance/types/tuple/arityAndOrderCompatibility01.ts(18,5): error TS2322: Type '[string, number]' is not assignable to type '[number, number, number]'.
Source has 2 element(s) but target requires 3.
tests/cases/conformance/types/tuple/arityAndOrderCompatibility01.ts(19,5): error TS2741: Property '2' is missing in type 'StrNum' but required in type '[number, number, number]'.
tests/cases/conformance/types/tuple/arityAndOrderCompatibility01.ts(20,5): error TS2322: Type '{ 0: string; 1: number; length: 2; }' is not assignable to type '[number, number, number]'.
tests/cases/conformance/types/tuple/arityAndOrderCompatibility01.ts(21,5): error TS2322: Type '[string, number]' is not assignable to type '[string, number, number]'.
Source has 2 element(s) but target requires 3.
tests/cases/conformance/types/tuple/arityAndOrderCompatibility01.ts(22,5): error TS2741: Property '2' is missing in type 'StrNum' but required in type '[string, number, number]'.
tests/cases/conformance/types/tuple/arityAndOrderCompatibility01.ts(23,5): error TS2322: Type '{ 0: string; 1: number; length: 2; }' is not assignable to type '[string, number, number]'.
tests/cases/conformance/types/tuple/arityAndOrderCompatibility01.ts(24,5): error TS2322: Type '[string, number]' is not assignable to type '[number]'.
Source has 2 element(s) but target allows only 1.
tests/cases/conformance/types/tuple/arityAndOrderCompatibility01.ts(25,5): error TS2322: Type 'StrNum' is not assignable to type '[number]'.
Types of property '0' are incompatible.
Type 'string' is not assignable to type 'number'.
tests/cases/conformance/types/tuple/arityAndOrderCompatibility01.ts(26,5): error TS2322: Type '{ 0: string; 1: number; length: 2; }' is not assignable to type '[number]'.
tests/cases/conformance/types/tuple/arityAndOrderCompatibility01.ts(27,5): error TS2322: Type '[string, number]' is not assignable to type '[string]'.
Source has 2 element(s) but target allows only 1.
tests/cases/conformance/types/tuple/arityAndOrderCompatibility01.ts(28,5): error TS2322: Type 'StrNum' is not assignable to type '[string]'.
Types of property 'length' are incompatible.
Type '2' is not assignable to type '1'.
tests/cases/conformance/types/tuple/arityAndOrderCompatibility01.ts(29,5): error TS2322: Type '{ 0: string; 1: number; length: 2; }' is not assignable to type '[string]'.
tests/cases/conformance/types/tuple/arityAndOrderCompatibility01.ts(30,5): error TS2322: Type '[string, number]' is not assignable to type '[number, string]'.
Type at position 0 in source is not compatible with type at position 0 in target.
Type 'string' is not assignable to type 'number'.
tests/cases/conformance/types/tuple/arityAndOrderCompatibility01.ts(31,5): error TS2322: Type 'StrNum' is not assignable to type '[number, string]'.
Types of property '0' are incompatible.
Type 'string' is not assignable to type 'number'.
tests/cases/conformance/types/tuple/arityAndOrderCompatibility01.ts(32,5): error TS2322: Type '{ 0: string; 1: number; length: 2; }' is not assignable to type '[number, string]'.
==== tests/cases/conformance/types/tuple/arityAndOrderCompatibility01.ts (17 errors) ====
interface StrNum extends Array<string|number> {
0: string;
1: number;
length: 2;
}
var x: [string, number];
var y: StrNum
var z: {
0: string;
1: number;
length: 2;
}
var [a, b, c] = x;
~
!!! error TS2493: Tuple type '[string, number]' of length '2' has no element at index '2'.
var [d, e, f] = y;
var [g, h, i] = z;
~~~~~~~~~
!!! error TS2461: Type '{ 0: string; 1: number; length: 2; }' is not an array type.
var j1: [number, number, number] = x;
~~
!!! error TS2322: Type '[string, number]' is not assignable to type '[number, number, number]'.
!!! error TS2322: Source has 2 element(s) but target requires 3.
var j2: [number, number, number] = y;
~~
!!! error TS2741: Property '2' is missing in type 'StrNum' but required in type '[number, number, number]'.
var j3: [number, number, number] = z;
~~
!!! error TS2322: Type '{ 0: string; 1: number; length: 2; }' is not assignable to type '[number, number, number]'.
var k1: [string, number, number] = x;
~~
!!! error TS2322: Type '[string, number]' is not assignable to type '[string, number, number]'.
!!! error TS2322: Source has 2 element(s) but target requires 3.
var k2: [string, number, number] = y;
~~
!!! error TS2741: Property '2' is missing in type 'StrNum' but required in type '[string, number, number]'.
var k3: [string, number, number] = z;
~~
!!! error TS2322: Type '{ 0: string; 1: number; length: 2; }' is not assignable to type '[string, number, number]'.
var l1: [number] = x;
~~
!!! error TS2322: Type '[string, number]' is not assignable to type '[number]'.
!!! error TS2322: Source has 2 element(s) but target allows only 1.
var l2: [number] = y;
~~
!!! error TS2322: Type 'StrNum' is not assignable to type '[number]'.
!!! error TS2322: Types of property '0' are incompatible.
!!! error TS2322: Type 'string' is not assignable to type 'number'.
var l3: [number] = z;
~~
!!! error TS2322: Type '{ 0: string; 1: number; length: 2; }' is not assignable to type '[number]'.
var m1: [string] = x;
~~
!!! error TS2322: Type '[string, number]' is not assignable to type '[string]'.
!!! error TS2322: Source has 2 element(s) but target allows only 1.
var m2: [string] = y;
~~
!!! error TS2322: Type 'StrNum' is not assignable to type '[string]'.
!!! error TS2322: Types of property 'length' are incompatible.
!!! error TS2322: Type '2' is not assignable to type '1'.
var m3: [string] = z;
~~
!!! error TS2322: Type '{ 0: string; 1: number; length: 2; }' is not assignable to type '[string]'.
var n1: [number, string] = x;
~~
!!! error TS2322: Type '[string, number]' is not assignable to type '[number, string]'.
!!! error TS2322: Type at position 0 in source is not compatible with type at position 0 in target.
!!! error TS2322: Type 'string' is not assignable to type 'number'.
var n2: [number, string] = y;
~~
!!! error TS2322: Type 'StrNum' is not assignable to type '[number, string]'.
!!! error TS2322: Types of property '0' are incompatible.
!!! error TS2322: Type 'string' is not assignable to type 'number'.
var n3: [number, string] = z;
~~
!!! error TS2322: Type '{ 0: string; 1: number; length: 2; }' is not assignable to type '[number, string]'.
var o1: [string, number] = x;
var o2: [string, number] = y;
var o3: [string, number] = y;