mirror of
https://github.com/hanzoai/tsgo.git
synced 2026-10-30 19:37:15 +00:00
34 lines
1.4 KiB
Plaintext
34 lines
1.4 KiB
Plaintext
assignmentCompatBetweenTupleAndArray.ts(17,1): error TS2322: Type '[number, string]' is not assignable to type 'number[]'.
|
|
Type 'string | number' is not assignable to type 'number'.
|
|
Type 'string' is not assignable to type 'number'.
|
|
assignmentCompatBetweenTupleAndArray.ts(18,1): error TS2322: Type '{}[]' is not assignable to type '[{}]'.
|
|
Target requires 1 element(s) but source may have fewer.
|
|
|
|
|
|
==== assignmentCompatBetweenTupleAndArray.ts (2 errors) ====
|
|
declare var numStrTuple: [number, string];
|
|
declare var numNumTuple: [number, number];
|
|
declare var numEmptyObjTuple: [number, {}];
|
|
declare var emptyObjTuple: [{}];
|
|
|
|
declare var numArray: number[];
|
|
declare var emptyObjArray: {}[];
|
|
|
|
// no error
|
|
numArray = numNumTuple;
|
|
emptyObjArray = emptyObjTuple;
|
|
emptyObjArray = numStrTuple;
|
|
emptyObjArray = numNumTuple;
|
|
emptyObjArray = numEmptyObjTuple;
|
|
|
|
// error
|
|
numArray = numStrTuple;
|
|
~~~~~~~~
|
|
!!! error TS2322: Type '[number, string]' is not assignable to type 'number[]'.
|
|
!!! error TS2322: Type 'string | number' is not assignable to type 'number'.
|
|
!!! error TS2322: Type 'string' is not assignable to type 'number'.
|
|
emptyObjTuple = emptyObjArray;
|
|
~~~~~~~~~~~~~
|
|
!!! error TS2322: Type '{}[]' is not assignable to type '[{}]'.
|
|
!!! error TS2322: Target requires 1 element(s) but source may have fewer.
|
|
|