23 lines
No EOL
1.2 KiB
Text
23 lines
No EOL
1.2 KiB
Text
tests/cases/compiler/typeArgumentConstraintResolution1.ts(4,12): error TS2345: Argument of type 'string' is not assignable to parameter of type 'Date'.
|
|
Property 'toDateString' is missing in type 'String'.
|
|
tests/cases/compiler/typeArgumentConstraintResolution1.ts(11,12): error TS2345: Argument of type 'string' is not assignable to parameter of type 'Date'.
|
|
|
|
|
|
==== tests/cases/compiler/typeArgumentConstraintResolution1.ts (2 errors) ====
|
|
function foo1<T extends Date>(test: T);
|
|
function foo1<T extends Number>(test: string);
|
|
function foo1<T extends String>(test: any) { }
|
|
foo1<Date>(""); // should error
|
|
~~
|
|
!!! error TS2345: Argument of type 'string' is not assignable to parameter of type 'Date'.
|
|
!!! error TS2345: Property 'toDateString' is missing in type 'String'.
|
|
|
|
|
|
|
|
function foo2<T extends Date>(test: T): T;
|
|
function foo2<T extends Number>(test: string): T;
|
|
function foo2<T extends String>(test: any): any { return null; }
|
|
foo2<Date>(""); // Type Date does not satisfy the constraint 'Number' for type parameter 'T extends Number'
|
|
~~
|
|
!!! error TS2345: Argument of type 'string' is not assignable to parameter of type 'Date'.
|
|
|