31 lines
2.2 KiB
Plaintext
31 lines
2.2 KiB
Plaintext
tests/cases/compiler/genericRestArgs.ts(2,12): error TS2453: The type argument for type parameter 'T' cannot be inferred from the usage. Consider specifying the type arguments explicitly.
|
|
Type argument candidate '1' is not a valid type argument because it is not a supertype of candidate '""'.
|
|
tests/cases/compiler/genericRestArgs.ts(5,34): error TS2345: Argument of type '""' is not assignable to parameter of type 'number'.
|
|
tests/cases/compiler/genericRestArgs.ts(10,12): error TS2453: The type argument for type parameter 'T' cannot be inferred from the usage. Consider specifying the type arguments explicitly.
|
|
Type argument candidate '1' is not a valid type argument because it is not a supertype of candidate '""'.
|
|
tests/cases/compiler/genericRestArgs.ts(12,30): error TS2345: Argument of type '1' is not assignable to parameter of type 'any[]'.
|
|
|
|
|
|
==== tests/cases/compiler/genericRestArgs.ts (4 errors) ====
|
|
function makeArrayG<T>(...items: T[]): T[] { return items; }
|
|
var a1Ga = makeArrayG(1, ""); // no error
|
|
~~~~~~~~~~
|
|
!!! error TS2453: The type argument for type parameter 'T' cannot be inferred from the usage. Consider specifying the type arguments explicitly.
|
|
!!! error TS2453: Type argument candidate '1' is not a valid type argument because it is not a supertype of candidate '""'.
|
|
var a1Gb = makeArrayG<any>(1, "");
|
|
var a1Gc = makeArrayG<Object>(1, "");
|
|
var a1Gd = makeArrayG<number>(1, ""); // error
|
|
~~
|
|
!!! error TS2345: Argument of type '""' is not assignable to parameter of type 'number'.
|
|
|
|
function makeArrayGOpt<T>(item1?: T, item2?: T, item3?: T) {
|
|
return [item1, item2, item3];
|
|
}
|
|
var a2Ga = makeArrayGOpt(1, "");
|
|
~~~~~~~~~~~~~
|
|
!!! error TS2453: The type argument for type parameter 'T' cannot be inferred from the usage. Consider specifying the type arguments explicitly.
|
|
!!! error TS2453: Type argument candidate '1' is not a valid type argument because it is not a supertype of candidate '""'.
|
|
var a2Gb = makeArrayG<any>(1, "");
|
|
var a2Gc = makeArrayG<any[]>(1, ""); // error
|
|
~
|
|
!!! error TS2345: Argument of type '1' is not assignable to parameter of type 'any[]'. |