Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 707ed69

Browse filesBrowse files
authored
Merge pull request microsoft#12366 from Microsoft/declarationsInFilesWithErrors
[Release 2.1] Fixes for microsoft#12291 and microsoft#12326: Declaration emit when there are errors in the source file
2 parents b8f6227 + 6f1c3b3 commit 707ed69
Copy full SHA for 707ed69

8 files changed

+62-1Lines changed: 62 additions & 1 deletion
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎src/compiler/declarationEmitter.ts‎

Copy file name to clipboardExpand all lines: src/compiler/declarationEmitter.ts
+8-1Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1037,6 +1037,10 @@ namespace ts {
10371037
diagnosticMessage = Diagnostics.Type_parameter_0_of_exported_function_has_or_is_using_private_name_1;
10381038
break;
10391039

1040+
case SyntaxKind.TypeAliasDeclaration:
1041+
diagnosticMessage = Diagnostics.Type_parameter_0_of_exported_type_alias_has_or_is_using_private_name_1;
1042+
break;
1043+
10401044
default:
10411045
Debug.fail("This is unknown parent for type parameter: " + node.parent.kind);
10421046
}
@@ -1143,7 +1147,10 @@ namespace ts {
11431147
const prevEnclosingDeclaration = enclosingDeclaration;
11441148
enclosingDeclaration = node;
11451149
emitTypeParameters(node.typeParameters);
1146-
emitHeritageClause(getInterfaceBaseTypeNodes(node), /*isImplementsList*/ false);
1150+
const interfaceExtendsTypes = filter(getInterfaceBaseTypeNodes(node), base => isEntityNameExpression(base.expression));
1151+
if (interfaceExtendsTypes && interfaceExtendsTypes.length) {
1152+
emitHeritageClause(interfaceExtendsTypes, /*isImplementsList*/ false);
1153+
}
11471154
write(" {");
11481155
writeLine();
11491156
increaseIndent();
Collapse file

‎src/compiler/diagnosticMessages.json‎

Copy file name to clipboardExpand all lines: src/compiler/diagnosticMessages.json
+4Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2276,6 +2276,10 @@
22762276
"category": "Error",
22772277
"code": 4082
22782278
},
2279+
"Type parameter '{0}' of exported type alias has or is using private name '{1}'.": {
2280+
"category": "Error",
2281+
"code": 4083
2282+
},
22792283
"Conflicting definitions for '{0}' found at '{1}' and '{2}'. Consider installing a specific version of this library to resolve the conflict.": {
22802284
"category": "Message",
22812285
"code": 4090
Collapse file
+9Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
tests/cases/compiler/declarationEmitInterfaceWithNonEntityNameExpressionHeritage.ts(3,25): error TS2499: An interface can only extend an identifier/qualified-name with optional type arguments.
2+
3+
4+
==== tests/cases/compiler/declarationEmitInterfaceWithNonEntityNameExpressionHeritage.ts (1 errors) ====
5+
6+
class A { }
7+
interface Class extends (typeof A) { }
8+
~~~~~~~~~~
9+
!!! error TS2499: An interface can only extend an identifier/qualified-name with optional type arguments.
Collapse file
+18Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
//// [declarationEmitInterfaceWithNonEntityNameExpressionHeritage.ts]
2+
3+
class A { }
4+
interface Class extends (typeof A) { }
5+
6+
//// [declarationEmitInterfaceWithNonEntityNameExpressionHeritage.js]
7+
var A = (function () {
8+
function A() {
9+
}
10+
return A;
11+
}());
12+
13+
14+
//// [declarationEmitInterfaceWithNonEntityNameExpressionHeritage.d.ts]
15+
declare class A {
16+
}
17+
interface Class {
18+
}
Collapse file
+11Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
tests/cases/compiler/declarationEmitTypeAliasTypeParameterExtendingUnknownSymbol.ts(2,18): error TS2304: Cannot find name 'Unknown'.
2+
tests/cases/compiler/declarationEmitTypeAliasTypeParameterExtendingUnknownSymbol.ts(2,18): error TS4083: Type parameter 'T' of exported type alias has or is using private name 'Unknown'.
3+
4+
5+
==== tests/cases/compiler/declarationEmitTypeAliasTypeParameterExtendingUnknownSymbol.ts (2 errors) ====
6+
7+
type A<T extends Unknown> = {}
8+
~~~~~~~
9+
!!! error TS2304: Cannot find name 'Unknown'.
10+
~~~~~~~
11+
!!! error TS4083: Type parameter 'T' of exported type alias has or is using private name 'Unknown'.
Collapse file
+5Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
//// [declarationEmitTypeAliasTypeParameterExtendingUnknownSymbol.ts]
2+
3+
type A<T extends Unknown> = {}
4+
5+
//// [declarationEmitTypeAliasTypeParameterExtendingUnknownSymbol.js]
Collapse file
+4Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
// @declaration: true
2+
3+
class A { }
4+
interface Class extends (typeof A) { }
Collapse file
+3Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
// @declaration: true
2+
3+
type A<T extends Unknown> = {}

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.