Add missing case to declaration diagnostic handler

This commit is contained in:
Wesley Wigham 2018-11-30 16:25:07 -08:00
parent 3d8668c3d4
commit fa8df0d32c
6 changed files with 45 additions and 0 deletions

View file

@ -410,6 +410,7 @@ namespace ts {
}
break;
case SyntaxKind.FunctionType:
case SyntaxKind.FunctionDeclaration:
diagnosticMessage = Diagnostics.Type_parameter_0_of_exported_function_has_or_is_using_private_name_1;
break;

View file

@ -0,0 +1,13 @@
tests/cases/compiler/declarationEmitLambdaWithMissingTypeParameterNoCrash.ts(2,27): error TS2304: Cannot find name 'T2'.
tests/cases/compiler/declarationEmitLambdaWithMissingTypeParameterNoCrash.ts(2,27): error TS4016: Type parameter 'T1' of exported function has or is using private name 'T2'.
==== tests/cases/compiler/declarationEmitLambdaWithMissingTypeParameterNoCrash.ts (2 errors) ====
export interface Foo {
preFetch: <T1 extends T2> (c: T1) => void; // Type T2 is not defined
~~
!!! error TS2304: Cannot find name 'T2'.
~~
!!! error TS4016: Type parameter 'T1' of exported function has or is using private name 'T2'.
}

View file

@ -0,0 +1,9 @@
//// [declarationEmitLambdaWithMissingTypeParameterNoCrash.ts]
export interface Foo {
preFetch: <T1 extends T2> (c: T1) => void; // Type T2 is not defined
}
//// [declarationEmitLambdaWithMissingTypeParameterNoCrash.js]
"use strict";
exports.__esModule = true;

View file

@ -0,0 +1,11 @@
=== tests/cases/compiler/declarationEmitLambdaWithMissingTypeParameterNoCrash.ts ===
export interface Foo {
>Foo : Symbol(Foo, Decl(declarationEmitLambdaWithMissingTypeParameterNoCrash.ts, 0, 0))
preFetch: <T1 extends T2> (c: T1) => void; // Type T2 is not defined
>preFetch : Symbol(Foo.preFetch, Decl(declarationEmitLambdaWithMissingTypeParameterNoCrash.ts, 0, 22))
>T1 : Symbol(T1, Decl(declarationEmitLambdaWithMissingTypeParameterNoCrash.ts, 1, 15))
>c : Symbol(c, Decl(declarationEmitLambdaWithMissingTypeParameterNoCrash.ts, 1, 31))
>T1 : Symbol(T1, Decl(declarationEmitLambdaWithMissingTypeParameterNoCrash.ts, 1, 15))
}

View file

@ -0,0 +1,7 @@
=== tests/cases/compiler/declarationEmitLambdaWithMissingTypeParameterNoCrash.ts ===
export interface Foo {
preFetch: <T1 extends T2> (c: T1) => void; // Type T2 is not defined
>preFetch : <T1 extends any>(c: T1) => void
>c : T1
}

View file

@ -0,0 +1,4 @@
// @declaration: true
export interface Foo {
preFetch: <T1 extends T2> (c: T1) => void; // Type T2 is not defined
}