Skip to content

Commit ffa9cf2

Browse files
author
Richard Lynch
committed
Update insertExportModifier to support VariableDeclarationList
Signed-off-by: Richard Lynch <[email protected]>
1 parent 99c6de4 commit ffa9cf2

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

src/services/textChanges.ts

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -780,8 +780,20 @@ namespace ts.textChanges {
780780
}
781781
}
782782

783-
public insertExportModifier(sourceFile: SourceFile, node: DeclarationStatement | VariableStatement): void {
784-
this.insertText(sourceFile, node.getStart(sourceFile), "export ");
783+
public insertExportModifier(
784+
sourceFile: SourceFile,
785+
node: DeclarationStatement | VariableStatement | VariableDeclarationList
786+
): void {
787+
Debug.assert(
788+
/*expression*/ !(isVariableDeclarationList(node) && node.declarations.length !== 1),
789+
/*message*/ "Only allow adding export modifier to variable lists with 1 element"
790+
);
791+
792+
this.insertText(
793+
sourceFile,
794+
node.getStart(sourceFile, /*includeJsDocComment*/ false),
795+
"export "
796+
);
785797
}
786798

787799
public insertImportSpecifierAtIndex(sourceFile: SourceFile, importSpecifier: ImportSpecifier, namedImports: NamedImports, index: number) {

0 commit comments

Comments
 (0)