Skip to content

Commit ceab31c

Browse files
authored
Port PR #10016 to Master (#10100)
* Treat namespaceExportDeclaration as declaration * Update baselines * wip - add tests * Add tests * Show "export namespace" for quick-info
1 parent b54aec1 commit ceab31c

28 files changed

+96
-16
lines changed

src/compiler/checker.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19691,7 +19691,7 @@ namespace ts {
1969119691
}
1969219692

1969319693
function checkGrammarTopLevelElementForRequiredDeclareModifier(node: Node): boolean {
19694-
// A declare modifier is required for any top level .d.ts declaration except export=, export default,
19694+
// A declare modifier is required for any top level .d.ts declaration except export=, export default, export as namespace
1969519695
// interfaces and imports categories:
1969619696
//
1969719697
// DeclarationElement:
@@ -19709,6 +19709,7 @@ namespace ts {
1970919709
node.kind === SyntaxKind.ImportEqualsDeclaration ||
1971019710
node.kind === SyntaxKind.ExportDeclaration ||
1971119711
node.kind === SyntaxKind.ExportAssignment ||
19712+
node.kind === SyntaxKind.NamespaceExportDeclaration ||
1971219713
(node.flags & NodeFlags.Ambient) ||
1971319714
(node.flags & (NodeFlags.Export | NodeFlags.Default))) {
1971419715

src/compiler/utilities.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1569,6 +1569,7 @@ namespace ts {
15691569
case SyntaxKind.MethodSignature:
15701570
case SyntaxKind.ModuleDeclaration:
15711571
case SyntaxKind.NamespaceImport:
1572+
case SyntaxKind.NamespaceExportDeclaration:
15721573
case SyntaxKind.Parameter:
15731574
case SyntaxKind.PropertyAssignment:
15741575
case SyntaxKind.PropertyDeclaration:

src/services/services.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4830,7 +4830,14 @@ namespace ts {
48304830
}
48314831
if (symbolFlags & SymbolFlags.Alias) {
48324832
addNewLineIfDisplayPartsExist();
4833-
displayParts.push(keywordPart(SyntaxKind.ImportKeyword));
4833+
if (symbol.declarations[0].kind === SyntaxKind.NamespaceExportDeclaration) {
4834+
displayParts.push(keywordPart(SyntaxKind.ExportKeyword));
4835+
displayParts.push(spacePart());
4836+
displayParts.push(keywordPart(SyntaxKind.NamespaceKeyword));
4837+
}
4838+
else {
4839+
displayParts.push(keywordPart(SyntaxKind.ImportKeyword));
4840+
}
48344841
displayParts.push(spacePart());
48354842
addFullSymbolName(symbol);
48364843
ts.forEach(symbol.declarations, declaration => {

tests/baselines/reference/umd-augmentation-1.symbols

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ var t = p.x;
3939
=== tests/cases/conformance/externalModules/node_modules/math2d/index.d.ts ===
4040

4141
export as namespace Math2d;
42+
>Math2d : Symbol(Math2d, Decl(index.d.ts, 0, 0))
4243

4344
export interface Point {
4445
>Point : Symbol(Point, Decl(index.d.ts, 1, 27))

tests/baselines/reference/umd-augmentation-1.types

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ var t = p.x;
4848
=== tests/cases/conformance/externalModules/node_modules/math2d/index.d.ts ===
4949

5050
export as namespace Math2d;
51-
>Math2d : any
51+
>Math2d : typeof Math2d
5252

5353
export interface Point {
5454
>Point : Point

tests/baselines/reference/umd-augmentation-2.symbols

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ var t = p.x;
3737
=== tests/cases/conformance/externalModules/node_modules/math2d/index.d.ts ===
3838

3939
export as namespace Math2d;
40+
>Math2d : Symbol(Math2d, Decl(index.d.ts, 0, 0))
4041

4142
export interface Point {
4243
>Point : Symbol(Point, Decl(index.d.ts, 1, 27))

tests/baselines/reference/umd-augmentation-2.types

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ var t = p.x;
4646
=== tests/cases/conformance/externalModules/node_modules/math2d/index.d.ts ===
4747

4848
export as namespace Math2d;
49-
>Math2d : any
49+
>Math2d : typeof Math2d
5050

5151
export interface Point {
5252
>Point : Point

tests/baselines/reference/umd-augmentation-3.symbols

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ var t = p.x;
3939
=== tests/cases/conformance/externalModules/node_modules/math2d/index.d.ts ===
4040

4141
export as namespace Math2d;
42+
>Math2d : Symbol(Math2d, Decl(index.d.ts, 0, 0))
4243

4344
export = M2D;
4445
>M2D : Symbol(M2D, Decl(index.d.ts, 3, 13))

tests/baselines/reference/umd-augmentation-3.types

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ var t = p.x;
4848
=== tests/cases/conformance/externalModules/node_modules/math2d/index.d.ts ===
4949

5050
export as namespace Math2d;
51-
>Math2d : any
51+
>Math2d : typeof Math2d
5252

5353
export = M2D;
5454
>M2D : typeof M2D

tests/baselines/reference/umd-augmentation-4.symbols

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ var t = p.x;
3737
=== tests/cases/conformance/externalModules/node_modules/math2d/index.d.ts ===
3838

3939
export as namespace Math2d;
40+
>Math2d : Symbol(Math2d, Decl(index.d.ts, 0, 0))
4041

4142
export = M2D;
4243
>M2D : Symbol(M2D, Decl(index.d.ts, 3, 13))

0 commit comments

Comments
 (0)