Merge pull request #28783 from weswigham/fix-typeparam-parent

Add missing case to declaration diagnostic handler
This commit is contained in:
Wesley Wigham 2018-12-03 09:15:38 -08:00 committed by GitHub
commit 03a98a2840
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 65 additions and 0 deletions

View File

@ -389,6 +389,7 @@ namespace ts {
diagnosticMessage = Diagnostics.Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1;
break;
case SyntaxKind.ConstructorType:
case SyntaxKind.ConstructSignature:
diagnosticMessage = Diagnostics.Type_parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_1;
break;
@ -410,6 +411,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,20 @@
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(3,33): error TS2304: Cannot find name 'T2'.
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'.
==== tests/cases/compiler/declarationEmitLambdaWithMissingTypeParameterNoCrash.ts (4 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'.
preFetcher: new <T1 extends T2> (c: T1) => void; // Type T2 is not defined
~~
!!! error TS2304: Cannot find name 'T2'.
~~
!!! error TS4006: Type parameter 'T1' of constructor signature from exported interface has or is using private name 'T2'.
}

View File

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

View File

@ -0,0 +1,17 @@
=== 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))
preFetcher: new <T1 extends T2> (c: T1) => void; // Type T2 is not defined
>preFetcher : Symbol(Foo.preFetcher, Decl(declarationEmitLambdaWithMissingTypeParameterNoCrash.ts, 1, 46))
>T1 : Symbol(T1, Decl(declarationEmitLambdaWithMissingTypeParameterNoCrash.ts, 2, 21))
>c : Symbol(c, Decl(declarationEmitLambdaWithMissingTypeParameterNoCrash.ts, 2, 37))
>T1 : Symbol(T1, Decl(declarationEmitLambdaWithMissingTypeParameterNoCrash.ts, 2, 21))
}

View File

@ -0,0 +1,11 @@
=== 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
preFetcher: new <T1 extends T2> (c: T1) => void; // Type T2 is not defined
>preFetcher : new <T1 extends any>(c: T1) => void
>c : T1
}

View File

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