Skip to content

Commit 6b64c88

Browse files
authored
Fix crash on missing parent pointer in binder when transpiling export as ns (microsoft#36387)
1 parent 751eb44 commit 6b64c88

File tree

4 files changed

+22
-0
lines changed

4 files changed

+22
-0
lines changed

src/compiler/binder.ts

+3
Original file line numberDiff line numberDiff line change
@@ -2608,6 +2608,9 @@ namespace ts {
26082608
declareSymbol(container.symbol.exports, container.symbol, node, SymbolFlags.ExportStar, SymbolFlags.None);
26092609
}
26102610
else if (isNamespaceExport(node.exportClause)) {
2611+
// declareSymbol walks up parents to find name text, parent _must_ be set
2612+
// but won't be set by the normal binder walk until `bindChildren` later on.
2613+
node.exportClause.parent = node;
26112614
declareSymbol(container.symbol.exports, container.symbol, node.exportClause, SymbolFlags.Alias, SymbolFlags.AliasExcludes);
26122615
}
26132616
}

src/testRunner/unittests/services/transpile.ts

+7
Original file line numberDiff line numberDiff line change
@@ -474,5 +474,12 @@ var x = 0;`, {
474474
transpilesCorrectly("Infer correct file extension", `const fn = <T>(a: T) => a`, {
475475
noSetFileName: true
476476
});
477+
478+
transpilesCorrectly("Export star as ns conflict does not crash", `
479+
var a;
480+
export { a as alias };
481+
export * as alias from './file';`, {
482+
noSetFileName: true
483+
});
477484
});
478485
}

tests/baselines/reference/transpile/Export star as ns conflict does not crash.js

+6
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tests/baselines/reference/transpile/Export star as ns conflict does not crash.oldTranspile.js

+6
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)