Skip to content

Commit 883c334

Browse files
committed
Update deprecated ts methods
1 parent 54fafad commit 883c334

File tree

2 files changed

+27
-6
lines changed

2 files changed

+27
-6
lines changed

common/api-review/functions-exp.api.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
55
```ts
66

7-
import { FirebaseApp } from '@firebase/app-exp';
7+
import { FirebaseApp } from '@firebase/app';
88
import { FirebaseError } from '@firebase/util';
99

1010
// @public

scripts/exp/ts-transform-import-path.js

Lines changed: 26 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -108,16 +108,37 @@ function transformNode(node, { pattern, template }) {
108108
const newName = replacePath(importPathWithQuotes, pattern, template);
109109

110110
if (newName) {
111-
const newNode = ts.getMutableClone(node);
112-
newNode.moduleSpecifier = ts.createLiteral(newName);
113-
return newNode;
111+
if (ts.isImportDeclaration(node)) {
112+
return ts.factory.updateImportDeclaration(
113+
node,
114+
node.decorators,
115+
node.modifiers,
116+
node.importClause,
117+
ts.factory.createStringLiteral(newName) // moduleSpecifier
118+
);
119+
} else if (ts.isExportDeclaration(node)) {
120+
return ts.factory.updateExportDeclaration(
121+
node,
122+
node.decorators,
123+
node.modifiers,
124+
node.isTypeOnly,
125+
node.exportClause,
126+
ts.factory.createStringLiteral(newName) // moduleSpecifier
127+
);
128+
}
129+
// Just in case.
130+
return node;
114131
}
115132
} else if (ts.isModuleDeclaration(node) && node.name) {
116133
const importPathWithQuotes = node.name.getText();
117134
const newName = replacePath(importPathWithQuotes, pattern, template);
118135
if (newName) {
119-
const newNode = ts.getMutableClone(node);
120-
newNode.name = ts.createLiteral(newName);
136+
const newNode = ts.factory.updateModuleDeclaration(
137+
node,
138+
node.decorators,
139+
node.modifiers,
140+
ts.factory.createStringLiteral(newName) // name
141+
);
121142
return newNode;
122143
}
123144
}

0 commit comments

Comments
 (0)