diff --git a/src/compiler/transformers/declarations/diagnostics.ts b/src/compiler/transformers/declarations/diagnostics.ts index 94d6994f8d2ef..b4c72c7901214 100644 --- a/src/compiler/transformers/declarations/diagnostics.ts +++ b/src/compiler/transformers/declarations/diagnostics.ts @@ -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; diff --git a/tests/baselines/reference/declarationEmitLambdaWithMissingTypeParameterNoCrash.errors.txt b/tests/baselines/reference/declarationEmitLambdaWithMissingTypeParameterNoCrash.errors.txt new file mode 100644 index 0000000000000..02718216afca4 --- /dev/null +++ b/tests/baselines/reference/declarationEmitLambdaWithMissingTypeParameterNoCrash.errors.txt @@ -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: (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 (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'. + } + \ No newline at end of file diff --git a/tests/baselines/reference/declarationEmitLambdaWithMissingTypeParameterNoCrash.js b/tests/baselines/reference/declarationEmitLambdaWithMissingTypeParameterNoCrash.js new file mode 100644 index 0000000000000..36d9b9f7ae3d8 --- /dev/null +++ b/tests/baselines/reference/declarationEmitLambdaWithMissingTypeParameterNoCrash.js @@ -0,0 +1,10 @@ +//// [declarationEmitLambdaWithMissingTypeParameterNoCrash.ts] +export interface Foo { + preFetch: (c: T1) => void; // Type T2 is not defined + preFetcher: new (c: T1) => void; // Type T2 is not defined +} + + +//// [declarationEmitLambdaWithMissingTypeParameterNoCrash.js] +"use strict"; +exports.__esModule = true; diff --git a/tests/baselines/reference/declarationEmitLambdaWithMissingTypeParameterNoCrash.symbols b/tests/baselines/reference/declarationEmitLambdaWithMissingTypeParameterNoCrash.symbols new file mode 100644 index 0000000000000..c7908a593c18a --- /dev/null +++ b/tests/baselines/reference/declarationEmitLambdaWithMissingTypeParameterNoCrash.symbols @@ -0,0 +1,17 @@ +=== tests/cases/compiler/declarationEmitLambdaWithMissingTypeParameterNoCrash.ts === +export interface Foo { +>Foo : Symbol(Foo, Decl(declarationEmitLambdaWithMissingTypeParameterNoCrash.ts, 0, 0)) + + preFetch: (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 (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)) +} + diff --git a/tests/baselines/reference/declarationEmitLambdaWithMissingTypeParameterNoCrash.types b/tests/baselines/reference/declarationEmitLambdaWithMissingTypeParameterNoCrash.types new file mode 100644 index 0000000000000..5f132c3dfe866 --- /dev/null +++ b/tests/baselines/reference/declarationEmitLambdaWithMissingTypeParameterNoCrash.types @@ -0,0 +1,11 @@ +=== tests/cases/compiler/declarationEmitLambdaWithMissingTypeParameterNoCrash.ts === +export interface Foo { + preFetch: (c: T1) => void; // Type T2 is not defined +>preFetch : (c: T1) => void +>c : T1 + + preFetcher: new (c: T1) => void; // Type T2 is not defined +>preFetcher : new (c: T1) => void +>c : T1 +} + diff --git a/tests/cases/compiler/declarationEmitLambdaWithMissingTypeParameterNoCrash.ts b/tests/cases/compiler/declarationEmitLambdaWithMissingTypeParameterNoCrash.ts new file mode 100644 index 0000000000000..1c5b9890db683 --- /dev/null +++ b/tests/cases/compiler/declarationEmitLambdaWithMissingTypeParameterNoCrash.ts @@ -0,0 +1,5 @@ +// @declaration: true +export interface Foo { + preFetch: (c: T1) => void; // Type T2 is not defined + preFetcher: new (c: T1) => void; // Type T2 is not defined +}