Skip to content

Commit fa8df0d

Browse files
committed
Add missing case to declaration diagnostic handler
1 parent 3d8668c commit fa8df0d

6 files changed

+45
-0
lines changed

src/compiler/transformers/declarations/diagnostics.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -410,6 +410,7 @@ namespace ts {
410410
}
411411
break;
412412

413+
case SyntaxKind.FunctionType:
413414
case SyntaxKind.FunctionDeclaration:
414415
diagnosticMessage = Diagnostics.Type_parameter_0_of_exported_function_has_or_is_using_private_name_1;
415416
break;
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
tests/cases/compiler/declarationEmitLambdaWithMissingTypeParameterNoCrash.ts(2,27): error TS2304: Cannot find name 'T2'.
2+
tests/cases/compiler/declarationEmitLambdaWithMissingTypeParameterNoCrash.ts(2,27): error TS4016: Type parameter 'T1' of exported function has or is using private name 'T2'.
3+
4+
5+
==== tests/cases/compiler/declarationEmitLambdaWithMissingTypeParameterNoCrash.ts (2 errors) ====
6+
export interface Foo {
7+
preFetch: <T1 extends T2> (c: T1) => void; // Type T2 is not defined
8+
~~
9+
!!! error TS2304: Cannot find name 'T2'.
10+
~~
11+
!!! error TS4016: Type parameter 'T1' of exported function has or is using private name 'T2'.
12+
}
13+
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
//// [declarationEmitLambdaWithMissingTypeParameterNoCrash.ts]
2+
export interface Foo {
3+
preFetch: <T1 extends T2> (c: T1) => void; // Type T2 is not defined
4+
}
5+
6+
7+
//// [declarationEmitLambdaWithMissingTypeParameterNoCrash.js]
8+
"use strict";
9+
exports.__esModule = true;
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
=== tests/cases/compiler/declarationEmitLambdaWithMissingTypeParameterNoCrash.ts ===
2+
export interface Foo {
3+
>Foo : Symbol(Foo, Decl(declarationEmitLambdaWithMissingTypeParameterNoCrash.ts, 0, 0))
4+
5+
preFetch: <T1 extends T2> (c: T1) => void; // Type T2 is not defined
6+
>preFetch : Symbol(Foo.preFetch, Decl(declarationEmitLambdaWithMissingTypeParameterNoCrash.ts, 0, 22))
7+
>T1 : Symbol(T1, Decl(declarationEmitLambdaWithMissingTypeParameterNoCrash.ts, 1, 15))
8+
>c : Symbol(c, Decl(declarationEmitLambdaWithMissingTypeParameterNoCrash.ts, 1, 31))
9+
>T1 : Symbol(T1, Decl(declarationEmitLambdaWithMissingTypeParameterNoCrash.ts, 1, 15))
10+
}
11+
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
=== tests/cases/compiler/declarationEmitLambdaWithMissingTypeParameterNoCrash.ts ===
2+
export interface Foo {
3+
preFetch: <T1 extends T2> (c: T1) => void; // Type T2 is not defined
4+
>preFetch : <T1 extends any>(c: T1) => void
5+
>c : T1
6+
}
7+
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
// @declaration: true
2+
export interface Foo {
3+
preFetch: <T1 extends T2> (c: T1) => void; // Type T2 is not defined
4+
}

0 commit comments

Comments
 (0)