Skip to content

Commit 4ae646b

Browse files
authored
fix: break when downgrading ?? and ?. syntax
1 parent 792a7f7 commit 4ae646b

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

packages/react-refresh/src/ReactFreshTypeScriptTransformer.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ export default function(opts = {}) {
2020
const refreshReg = ts.createIdentifier(opts.refreshReg || '$RefreshReg$');
2121
const refreshSig = ts.createIdentifier(opts.refreshSig || '$RefreshSig$');
2222
return context => {
23+
let uniqueName = 0;
2324
return file => {
2425
if (file.isDeclarationFile) return file;
2526
const containHooksLikeOrJSX =
@@ -235,7 +236,9 @@ export default function(opts = {}) {
235236
};
236237
}
237238
function createTempVariable() {
238-
return ts.createTempVariable(context.hoistVariableDeclaration);
239+
const id = ts.createFileLevelUniqueName('$c' + uniqueName++);
240+
context.hoistVariableDeclaration(id);
241+
return id;
239242
}
240243
/**
241244
* ! This function does not consider variable shadowing !

0 commit comments

Comments
 (0)