File tree Expand file tree Collapse file tree 3 files changed +82
-0
lines changed Expand file tree Collapse file tree 3 files changed +82
-0
lines changed Original file line number Diff line number Diff line change
1
+ tests/cases/compiler/genericTypeConstraints.ts(9,27): error TS2344: Type 'FooExtended' does not satisfy the constraint 'Foo'.
2
+ Property 'fooMethod' is missing in type 'FooExtended'.
3
+ tests/cases/compiler/genericTypeConstraints.ts(9,31): error TS2344: Type 'FooExtended' does not satisfy the constraint 'Foo'.
4
+
5
+
6
+ ==== tests/cases/compiler/genericTypeConstraints.ts (2 errors) ====
7
+ class Foo {
8
+ fooMethod() {}
9
+ }
10
+
11
+ class FooExtended { }
12
+
13
+ class Bar<T extends Foo> { }
14
+
15
+ class BarExtended extends Bar<FooExtended> {
16
+ ~~~~~~~~~~~~~~~~
17
+ !!! error TS2344: Type 'FooExtended' does not satisfy the constraint 'Foo'.
18
+ !!! error TS2344: Property 'fooMethod' is missing in type 'FooExtended'.
19
+ ~~~~~~~~~~~
20
+ !!! error TS2344: Type 'FooExtended' does not satisfy the constraint 'Foo'.
21
+ constructor() {
22
+ super();
23
+ }
24
+ }
Original file line number Diff line number Diff line change
1
+ //// [genericTypeConstraints.ts]
2
+ class Foo {
3
+ fooMethod ( ) { }
4
+ }
5
+
6
+ class FooExtended { }
7
+
8
+ class Bar < T extends Foo > { }
9
+
10
+ class BarExtended extends Bar< FooExtended > {
11
+ constructor ( ) {
12
+ super ( ) ;
13
+ }
14
+ }
15
+
16
+ //// [genericTypeConstraints.js]
17
+ var __extends = ( this && this . __extends ) || function ( d , b ) {
18
+ for ( var p in b ) if ( b . hasOwnProperty ( p ) ) d [ p ] = b [ p ] ;
19
+ function __ ( ) { this . constructor = d ; }
20
+ __ . prototype = b . prototype ;
21
+ d . prototype = new __ ( ) ;
22
+ } ;
23
+ var Foo = ( function ( ) {
24
+ function Foo ( ) {
25
+ }
26
+ Foo . prototype . fooMethod = function ( ) { } ;
27
+ return Foo ;
28
+ } ) ( ) ;
29
+ var FooExtended = ( function ( ) {
30
+ function FooExtended ( ) {
31
+ }
32
+ return FooExtended ;
33
+ } ) ( ) ;
34
+ var Bar = ( function ( ) {
35
+ function Bar ( ) {
36
+ }
37
+ return Bar ;
38
+ } ) ( ) ;
39
+ var BarExtended = ( function ( _super ) {
40
+ __extends ( BarExtended , _super ) ;
41
+ function BarExtended ( ) {
42
+ _super . call ( this ) ;
43
+ }
44
+ return BarExtended ;
45
+ } ) ( Bar ) ;
Original file line number Diff line number Diff line change
1
+ class Foo {
2
+ fooMethod ( ) { }
3
+ }
4
+
5
+ class FooExtended { }
6
+
7
+ class Bar < T extends Foo > { }
8
+
9
+ class BarExtended extends Bar < FooExtended > {
10
+ constructor ( ) {
11
+ super ( ) ;
12
+ }
13
+ }
You can’t perform that action at this time.
0 commit comments