Skip to content

Fixes for #12291 and #12326: Declaration emit when there are errors in the source file #12363

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Nov 18, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion src/compiler/declarationEmitter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1037,6 +1037,10 @@ namespace ts {
diagnosticMessage = Diagnostics.Type_parameter_0_of_exported_function_has_or_is_using_private_name_1;
break;

case SyntaxKind.TypeAliasDeclaration:
diagnosticMessage = Diagnostics.Type_parameter_0_of_exported_type_alias_has_or_is_using_private_name_1;
break;

default:
Debug.fail("This is unknown parent for type parameter: " + node.parent.kind);
}
Expand Down Expand Up @@ -1143,7 +1147,10 @@ namespace ts {
const prevEnclosingDeclaration = enclosingDeclaration;
enclosingDeclaration = node;
emitTypeParameters(node.typeParameters);
emitHeritageClause(getInterfaceBaseTypeNodes(node), /*isImplementsList*/ false);
const interfaceExtendsTypes = filter(getInterfaceBaseTypeNodes(node), base => isEntityNameExpression(base.expression));
if (interfaceExtendsTypes && interfaceExtendsTypes.length) {
emitHeritageClause(interfaceExtendsTypes, /*isImplementsList*/ false);
}
write(" {");
writeLine();
increaseIndent();
Expand Down
4 changes: 4 additions & 0 deletions src/compiler/diagnosticMessages.json
Original file line number Diff line number Diff line change
Expand Up @@ -2276,6 +2276,10 @@
"category": "Error",
"code": 4082
},
"Type parameter '{0}' of exported type alias has or is using private name '{1}'.": {
"category": "Error",
"code": 4083
},
"Conflicting definitions for '{0}' found at '{1}' and '{2}'. Consider installing a specific version of this library to resolve the conflict.": {
"category": "Message",
"code": 4090
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
tests/cases/compiler/declarationEmitInterfaceWithNonEntityNameExpressionHeritage.ts(3,25): error TS2499: An interface can only extend an identifier/qualified-name with optional type arguments.


==== tests/cases/compiler/declarationEmitInterfaceWithNonEntityNameExpressionHeritage.ts (1 errors) ====

class A { }
interface Class extends (typeof A) { }
~~~~~~~~~~
!!! error TS2499: An interface can only extend an identifier/qualified-name with optional type arguments.
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
//// [declarationEmitInterfaceWithNonEntityNameExpressionHeritage.ts]

class A { }
interface Class extends (typeof A) { }

//// [declarationEmitInterfaceWithNonEntityNameExpressionHeritage.js]
var A = (function () {
function A() {
}
return A;
}());


//// [declarationEmitInterfaceWithNonEntityNameExpressionHeritage.d.ts]
declare class A {
}
interface Class {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
tests/cases/compiler/declarationEmitTypeAliasTypeParameterExtendingUnknownSymbol.ts(2,18): error TS2304: Cannot find name 'Unknown'.
tests/cases/compiler/declarationEmitTypeAliasTypeParameterExtendingUnknownSymbol.ts(2,18): error TS4083: Type parameter 'T' of exported type alias has or is using private name 'Unknown'.


==== tests/cases/compiler/declarationEmitTypeAliasTypeParameterExtendingUnknownSymbol.ts (2 errors) ====

type A<T extends Unknown> = {}
~~~~~~~
!!! error TS2304: Cannot find name 'Unknown'.
~~~~~~~
!!! error TS4083: Type parameter 'T' of exported type alias has or is using private name 'Unknown'.
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
//// [declarationEmitTypeAliasTypeParameterExtendingUnknownSymbol.ts]

type A<T extends Unknown> = {}

//// [declarationEmitTypeAliasTypeParameterExtendingUnknownSymbol.js]
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
// @declaration: true

class A { }
interface Class extends (typeof A) { }
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
// @declaration: true

type A<T extends Unknown> = {}