5540364c12
* Fix relations for optional elements in tuples with --strictOptionalProperties * Accept new baselines * Add regression test * Address CR feedback
80 lines
6.6 KiB
Plaintext
80 lines
6.6 KiB
Plaintext
tests/cases/conformance/types/tuple/castingTuple.ts(13,23): error TS2352: Conversion of type '[number, string]' to type '[number, string, boolean]' may be a mistake because neither type sufficiently overlaps with the other. If this was intentional, convert the expression to 'unknown' first.
|
|
Source has 2 element(s) but target requires 3.
|
|
tests/cases/conformance/types/tuple/castingTuple.ts(14,15): error TS2352: Conversion of type '[number, string, boolean]' to type '[number, string]' may be a mistake because neither type sufficiently overlaps with the other. If this was intentional, convert the expression to 'unknown' first.
|
|
Source has 3 element(s) but target allows only 2.
|
|
tests/cases/conformance/types/tuple/castingTuple.ts(15,14): error TS2352: Conversion of type '[number, string]' to type '[number, string, boolean]' may be a mistake because neither type sufficiently overlaps with the other. If this was intentional, convert the expression to 'unknown' first.
|
|
tests/cases/conformance/types/tuple/castingTuple.ts(18,21): error TS2352: Conversion of type '[C, D]' to type '[C, D, A]' may be a mistake because neither type sufficiently overlaps with the other. If this was intentional, convert the expression to 'unknown' first.
|
|
Source has 2 element(s) but target requires 3.
|
|
tests/cases/conformance/types/tuple/castingTuple.ts(20,33): error TS2493: Tuple type '[C, D, A]' of length '3' has no element at index '5'.
|
|
tests/cases/conformance/types/tuple/castingTuple.ts(30,10): error TS2352: Conversion of type '[number, string]' to type '[number, number]' may be a mistake because neither type sufficiently overlaps with the other. If this was intentional, convert the expression to 'unknown' first.
|
|
Type at position 1 in source is not compatible with type at position 1 in target.
|
|
Type 'string' is not comparable to type 'number'.
|
|
tests/cases/conformance/types/tuple/castingTuple.ts(31,10): error TS2352: Conversion of type '[C, D]' to type '[A, I]' may be a mistake because neither type sufficiently overlaps with the other. If this was intentional, convert the expression to 'unknown' first.
|
|
Type at position 0 in source is not compatible with type at position 0 in target.
|
|
Property 'a' is missing in type 'C' but required in type 'A'.
|
|
tests/cases/conformance/types/tuple/castingTuple.ts(32,5): error TS2403: Subsequent variable declarations must have the same type. Variable 'array1' must be of type '{}[]', but here has type 'number[]'.
|
|
tests/cases/conformance/types/tuple/castingTuple.ts(33,1): error TS2304: Cannot find name 't4'.
|
|
|
|
|
|
==== tests/cases/conformance/types/tuple/castingTuple.ts (9 errors) ====
|
|
interface I { }
|
|
class A { a = 10; }
|
|
class C implements I { c };
|
|
class D implements I { d };
|
|
class E extends A { e };
|
|
class F extends A { f };
|
|
enum E1 { one }
|
|
enum E2 { one }
|
|
|
|
// no error
|
|
var numStrTuple: [number, string] = [5, "foo"];
|
|
var emptyObjTuple = <[{}, {}]>numStrTuple;
|
|
var numStrBoolTuple = <[number, string, boolean]>numStrTuple;
|
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
!!! error TS2352: Conversion of type '[number, string]' to type '[number, string, boolean]' may be a mistake because neither type sufficiently overlaps with the other. If this was intentional, convert the expression to 'unknown' first.
|
|
!!! error TS2352: Source has 2 element(s) but target requires 3.
|
|
var shorter = numStrBoolTuple as [number, string]
|
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
!!! error TS2352: Conversion of type '[number, string, boolean]' to type '[number, string]' may be a mistake because neither type sufficiently overlaps with the other. If this was intentional, convert the expression to 'unknown' first.
|
|
!!! error TS2352: Source has 3 element(s) but target allows only 2.
|
|
var longer = numStrTuple as [number, string, boolean]
|
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
!!! error TS2352: Conversion of type '[number, string]' to type '[number, string, boolean]' may be a mistake because neither type sufficiently overlaps with the other. If this was intentional, convert the expression to 'unknown' first.
|
|
var classCDTuple: [C, D] = [new C(), new D()];
|
|
var interfaceIITuple = <[I, I]>classCDTuple;
|
|
var classCDATuple = <[C, D, A]>classCDTuple;
|
|
~~~~~~~~~~~~~~~~~~~~~~~
|
|
!!! error TS2352: Conversion of type '[C, D]' to type '[C, D, A]' may be a mistake because neither type sufficiently overlaps with the other. If this was intentional, convert the expression to 'unknown' first.
|
|
!!! error TS2352: Source has 2 element(s) but target requires 3.
|
|
var eleFromCDA1 = classCDATuple[2]; // A
|
|
var eleFromCDA2 = classCDATuple[5]; // C | D | A
|
|
~
|
|
!!! error TS2493: Tuple type '[C, D, A]' of length '3' has no element at index '5'.
|
|
var t10: [E1, E2] = [E1.one, E2.one];
|
|
var t11 = <[number, number]>t10;
|
|
var array1 = <{}[]>emptyObjTuple;
|
|
var unionTuple: [C, string | number] = [new C(), "foo"];
|
|
var unionTuple2: [C, string | number, D] = [new C(), "foo", new D()];
|
|
var unionTuple3: [number, string| number] = [10, "foo"];
|
|
var unionTuple4 = <[number, number]>unionTuple3;
|
|
|
|
// error
|
|
var t3 = <[number, number]>numStrTuple;
|
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
!!! error TS2352: Conversion of type '[number, string]' to type '[number, number]' may be a mistake because neither type sufficiently overlaps with the other. If this was intentional, convert the expression to 'unknown' first.
|
|
!!! error TS2352: Type at position 1 in source is not compatible with type at position 1 in target.
|
|
!!! error TS2352: Type 'string' is not comparable to type 'number'.
|
|
var t9 = <[A, I]>classCDTuple;
|
|
~~~~~~~~~~~~~~~~~~~~
|
|
!!! error TS2352: Conversion of type '[C, D]' to type '[A, I]' may be a mistake because neither type sufficiently overlaps with the other. If this was intentional, convert the expression to 'unknown' first.
|
|
!!! error TS2352: Type at position 0 in source is not compatible with type at position 0 in target.
|
|
!!! error TS2352: Property 'a' is missing in type 'C' but required in type 'A'.
|
|
!!! related TS2728 tests/cases/conformance/types/tuple/castingTuple.ts:2:11: 'a' is declared here.
|
|
var array1 = <number[]>numStrTuple;
|
|
~~~~~~
|
|
!!! error TS2403: Subsequent variable declarations must have the same type. Variable 'array1' must be of type '{}[]', but here has type 'number[]'.
|
|
!!! related TS6203 tests/cases/conformance/types/tuple/castingTuple.ts:23:5: 'array1' was also declared here.
|
|
t4[2] = 10;
|
|
~~
|
|
!!! error TS2304: Cannot find name 't4'.
|
|
|