Skip to content

Commit 792a7f7

Browse files
committed
chore: move ts into opts
1 parent 775abee commit 792a7f7

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

packages/react-refresh/src/ReactFreshTypeScriptTransformer.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,17 @@
66
* This transformer requires TypeScript to be at least 3.9.
77
*
88
* @param {opt} opts Options
9-
* @param {ts} ts TypeScript compiler
109
* @returns {import('typescript').TransformerFactory<SourceFile>}
1110
*/
12-
export default function(opts = {}, ts = require('typescript')) {
11+
export default function(opts = {}) {
12+
const ts = opts.ts || require('typescript');
1313
{
1414
const [major, minor] = ts.version.split('.');
1515
const num = parseInt(major);
1616
const msg = 'TypeScript should be at least 3.9';
1717
if (num < 3) throw new Error(msg);
1818
if (num === 3 && parseInt(minor) !== 9) throw new Error(msg);
1919
}
20-
const printer = ts.createPrinter();
2120
const refreshReg = ts.createIdentifier(opts.refreshReg || '$RefreshReg$');
2221
const refreshSig = ts.createIdentifier(opts.refreshSig || '$RefreshSig$');
2322
return context => {
@@ -754,7 +753,7 @@ function startsWithLowerCase(str) {
754753
return str[0].toLowerCase() === str[0];
755754
}
756755

757-
/** @typedef {{refreshReg?: string, refreshSig?: string, emitFullSignatures?: boolean}} opt */
756+
/** @typedef {{refreshReg?: string, refreshSig?: string, emitFullSignatures?: boolean, ts?: ts}} opt */
758757
/** @typedef {import('typescript')} ts */
759758
/** @typedef {import('typescript').Node} Node */
760759
/** @typedef {import('typescript').Statement} Statement */

0 commit comments

Comments
 (0)