10000 Fixed invalid assertion in ts transformer · prmdeveloper/TypeScript@1cf183b · GitHub
[go: up one dir, main page]

Skip to content

Commit 1cf183b

Browse files
committed
Fixed invalid assertion in ts transformer
1 parent 72eebdb commit 1cf183b

File tree

1 file changed

+16
-13
lines changed
  • src/compiler/transformers

1 file changed

+16
-13
lines changed

src/compiler/transformers/ts.ts

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2105,21 +2105,24 @@ namespace ts {
21052105
* This function will be called when one of the following conditions are met:
21062106
* - The node is exported from a TypeScript namespace.
21072107
*/
2108-
function visitVariableStatement(node: VariableStatement) {
2109-
Debug.assert(isNamespaceExport(node));
2108+
function visitVariableStatement(node: VariableStatement): Statement {
2109+
if (isNamespaceExport(node)) {
2110+
const variables = getInitializedVariables(node.declarationList);
2111+
if (variables.length === 0) {
2112+
// elide statement if there are no initialized variables.
2113+
return undefined;
2114+
}
21102115

2111-
const variables = getInitializedVariables(node.declarationList);
2112-
if (variables.length === 0) {
2113-
// elide statement if there are no initialized variables.
2114-
return undefined;
2116+
return createStatement(
2117+
inlineExpressions(
2118+
map(variables, transformInitializedVariable)
2119+
),
2120+
/*location*/ node
2121+
);
2122+
}
2123+
else {
2124+
return visitEachChild(node, visitor, context);
21152125
}
2116-
2117-
return createStatement(
2118-
inlineExpressions(
2119-
map(variables, transformInitializedVariable)
2120-
),
2121-
/*location*/ node
2122-
);
21232126
}
21242127

21252128
function transformInitializedVariable(node: VariableDeclaration): Expression {

0 commit comments

Comments
 (0)
0