mirror of
https://github.com/hanzoai/tsgo.git
synced 2026-10-30 19:37:15 +00:00
31 lines
1.5 KiB
Plaintext
31 lines
1.5 KiB
Plaintext
commaOperatorOtherInvalidOperation.ts(6,5): error TS2322: Type 'string' is not assignable to type 'number'.
|
|
commaOperatorOtherInvalidOperation.ts(12,9): error TS2322: Type 'T2' is not assignable to type 'T1'.
|
|
'T1' could be instantiated with an arbitrary type which could be unrelated to 'T2'.
|
|
commaOperatorOtherInvalidOperation.ts(12,23): error TS2454: Variable 'x' is used before being assigned.
|
|
commaOperatorOtherInvalidOperation.ts(12,26): error TS2454: Variable 'y' is used before being assigned.
|
|
|
|
|
|
==== commaOperatorOtherInvalidOperation.ts (4 errors) ====
|
|
//Expect to have compiler errors
|
|
//Comma operator in function arguments and return
|
|
function foo(x: number, y: string) {
|
|
return x, y;
|
|
}
|
|
var resultIsString: number = foo(1, "123"); //error here
|
|
~~~~~~~~~~~~~~
|
|
!!! error TS2322: Type 'string' is not assignable to type 'number'.
|
|
|
|
//TypeParameters
|
|
function foo1<T1, T2>() {
|
|
var x: T1;
|
|
var y: T2;
|
|
var result: T1 = (x, y); //error here
|
|
~~~~~~
|
|
!!! error TS2322: Type 'T2' is not assignable to type 'T1'.
|
|
!!! error TS2322: 'T1' could be instantiated with an arbitrary type which could be unrelated to 'T2'.
|
|
!!! related TS2208 commaOperatorOtherInvalidOperation.ts:9:19: This type parameter might need an `extends T1` constraint.
|
|
~
|
|
!!! error TS2454: Variable 'x' is used before being assigned.
|
|
~
|
|
!!! error TS2454: Variable 'y' is used before being assigned.
|
|
} |