Skip to content

Commit cd6fdb1

Browse files
committed
Add constructor case
1 parent fa8df0d commit cd6fdb1

6 files changed

+21
-1
lines changed

src/compiler/transformers/declarations/diagnostics.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -389,6 +389,7 @@ namespace ts {
389389
diagnosticMessage = Diagnostics.Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1;
390390
break;
391391

392+
case SyntaxKind.ConstructorType:
392393
case SyntaxKind.ConstructSignature:
393394
diagnosticMessage = Diagnostics.Type_parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_1;
394395
break;
Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,20 @@
11
tests/cases/compiler/declarationEmitLambdaWithMissingTypeParameterNoCrash.ts(2,27): error TS2304: Cannot find name 'T2'.
22
tests/cases/compiler/declarationEmitLambdaWithMissingTypeParameterNoCrash.ts(2,27): error TS4016: Type parameter 'T1' of exported function has or is using private name 'T2'.
3+
tests/cases/compiler/declarationEmitLambdaWithMissingTypeParameterNoCrash.ts(3,33): error TS2304: Cannot find name 'T2'.
4+
tests/cases/compiler/declarationEmitLambdaWithMissingTypeParameterNoCrash.ts(3,33): error TS4006: Type parameter 'T1' of constructor signature from exported interface has or is using private name 'T2'.
35

46

5-
==== tests/cases/compiler/declarationEmitLambdaWithMissingTypeParameterNoCrash.ts (2 errors) ====
7+
==== tests/cases/compiler/declarationEmitLambdaWithMissingTypeParameterNoCrash.ts (4 errors) ====
68
export interface Foo {
79
preFetch: <T1 extends T2> (c: T1) => void; // Type T2 is not defined
810
~~
911
!!! error TS2304: Cannot find name 'T2'.
1012
~~
1113
!!! error TS4016: Type parameter 'T1' of exported function has or is using private name 'T2'.
14+
preFetcher: new <T1 extends T2> (c: T1) => void; // Type T2 is not defined
15+
~~
16+
!!! error TS2304: Cannot find name 'T2'.
17+
~~
18+
!!! error TS4006: Type parameter 'T1' of constructor signature from exported interface has or is using private name 'T2'.
1219
}
1320

tests/baselines/reference/declarationEmitLambdaWithMissingTypeParameterNoCrash.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
//// [declarationEmitLambdaWithMissingTypeParameterNoCrash.ts]
22
export interface Foo {
33
preFetch: <T1 extends T2> (c: T1) => void; // Type T2 is not defined
4+
preFetcher: new <T1 extends T2> (c: T1) => void; // Type T2 is not defined
45
}
56

67

tests/baselines/reference/declarationEmitLambdaWithMissingTypeParameterNoCrash.symbols

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,11 @@ export interface Foo {
77
>T1 : Symbol(T1, Decl(declarationEmitLambdaWithMissingTypeParameterNoCrash.ts, 1, 15))
88
>c : Symbol(c, Decl(declarationEmitLambdaWithMissingTypeParameterNoCrash.ts, 1, 31))
99
>T1 : Symbol(T1, Decl(declarationEmitLambdaWithMissingTypeParameterNoCrash.ts, 1, 15))
10+
11+
preFetcher: new <T1 extends T2> (c: T1) => void; // Type T2 is not defined
12+
>preFetcher : Symbol(Foo.preFetcher, Decl(declarationEmitLambdaWithMissingTypeParameterNoCrash.ts, 1, 46))
13+
>T1 : Symbol(T1, Decl(declarationEmitLambdaWithMissingTypeParameterNoCrash.ts, 2, 21))
14+
>c : Symbol(c, Decl(declarationEmitLambdaWithMissingTypeParameterNoCrash.ts, 2, 37))
15+
>T1 : Symbol(T1, Decl(declarationEmitLambdaWithMissingTypeParameterNoCrash.ts, 2, 21))
1016
}
1117

tests/baselines/reference/declarationEmitLambdaWithMissingTypeParameterNoCrash.types

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22
export interface Foo {
33
preFetch: <T1 extends T2> (c: T1) => void; // Type T2 is not defined
44
>preFetch : <T1 extends any>(c: T1) => void
5+
>c : T1
6+
7+
preFetcher: new <T1 extends T2> (c: T1) => void; // Type T2 is not defined
8+
>preFetcher : new <T1 extends any>(c: T1) => void
59
>c : T1
610
}
711

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
// @declaration: true
22
export interface Foo {
33
preFetch: <T1 extends T2> (c: T1) => void; // Type T2 is not defined
4+
preFetcher: new <T1 extends T2> (c: T1) => void; // Type T2 is not defined
45
}

0 commit comments

Comments
 (0)