Skip to content

Commit 166eb54

Browse files
committed
Fixed the "Unsupported re-export" bug
1 parent 4582454 commit 166eb54

File tree

2 files changed

+30
-12
lines changed

2 files changed

+30
-12
lines changed

apps/api-extractor/src/generators/PackageTypingsGenerator.ts

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,26 @@ export default class PackageTypingsGenerator {
178178
private static _followAliases(symbol: ts.Symbol, typeChecker: ts.TypeChecker): IFollowAliasesResult {
179179
let current: ts.Symbol = symbol;
180180

181+
// Is it ambient? We will examine all of the declarations we encounter
182+
// to see if any of them contains the "export" keyword; if not, then it's ambient.
183+
let isAmbient: boolean = true;
184+
181185
while (true) { // tslint:disable-line:no-constant-condition
186+
187+
for (const declaration of current.declarations || []) {
188+
if (declaration.kind === ts.SyntaxKind.ExportSpecifier
189+
|| declaration.kind === ts.SyntaxKind.ExportAssignment) {
190+
isAmbient = false;
191+
break;
192+
}
193+
194+
const modifiers: ts.ModifierFlags = ts.getCombinedModifierFlags(declaration);
195+
if (modifiers & (ts.ModifierFlags.Export | ts.ModifierFlags.ExportDefault)) {
196+
isAmbient = false;
197+
break;
198+
}
199+
}
200+
182201
if (!(current.flags & ts.SymbolFlags.Alias)) {
183202
break;
184203
}
@@ -228,17 +247,6 @@ export default class PackageTypingsGenerator {
228247
current = currentAlias;
229248
}
230249

231-
// Is it ambient? We examine all of the declarations to see if any of them contains
232-
// the "export" keyword; if not, then it's ambient.
233-
let isAmbient: boolean = true;
234-
for (const declaration of current.declarations || []) {
235-
const modifiers: ts.ModifierFlags = ts.getCombinedModifierFlags(declaration);
236-
if (modifiers & (ts.ModifierFlags.Export | ts.ModifierFlags.ExportDefault)) {
237-
isAmbient = false;
238-
break;
239-
}
240-
}
241-
242250
return {
243251
symbol: current,
244252
importPackagePath: undefined,

build-tests/api-extractor-test-01/dist/index-internal.d.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
// Unsupported re-export: IInterfaceAsDefaultExport
21
/**
32
* Example documentation for the package.
43
*
@@ -75,6 +74,17 @@ declare interface IForgottenExport_2 {
7574
instance2: string;
7675
}
7776

77+
/**
78+
* This interface is exported as the default export for its source file.
79+
* @public
80+
*/
81+
export declare interface IInterfaceAsDefaultExport {
82+
/**
83+
* A member of the interface
84+
*/
85+
member: string;
86+
}
87+
7888
/**
7989
* A simple, normal definition
8090
* @public

0 commit comments

Comments
 (0)