26 lines
1.1 KiB
Text
26 lines
1.1 KiB
Text
|
==== tests/cases/compiler/typeParameterConstraints1.ts (6 errors) ====
|
||
|
function foo1<T extends any>(test: T) { }
|
||
|
function foo2<T extends number>(test: T) { }
|
||
|
function foo3<T extends string>(test: T) { }
|
||
|
function foo4<T extends Date>(test: T) { } // valid
|
||
|
function foo5<T extends RegExp>(test: T) { } // valid
|
||
|
function foo6<T extends hm>(test: T) { }
|
||
|
~~
|
||
|
!!! Cannot find name 'hm'.
|
||
|
function foo7<T extends Object>(test: T) { } // valid
|
||
|
function foo8<T extends "">(test: T) { }
|
||
|
~~
|
||
|
!!! Type expected.
|
||
|
function foo9<T extends 1 > (test: T) { }
|
||
|
~
|
||
|
!!! Type expected.
|
||
|
function foo10<T extends (1)> (test: T) { }
|
||
|
~~~
|
||
|
!!! Type expected.
|
||
|
function foo11<T extends null> (test: T) { }
|
||
|
~~~~
|
||
|
!!! Type expected.
|
||
|
function foo12<T extends undefined>(test: T) { }
|
||
|
~~~~~~~~~
|
||
|
!!! Cannot find name 'undefined'.
|
||
|
function foo13<T extends void>(test: T) { }
|