Skip to content

Commit 88e7d42

Browse files
committed
Check for ts and tsx
1 parent 49c1638 commit 88e7d42

File tree

1 file changed

+4
-3
lines changed
  • packages/react-scripts/scripts

1 file changed

+4
-3
lines changed

packages/react-scripts/scripts/init.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -148,13 +148,14 @@ module.exports = function(
148148
path.resolve(appSrc, f)
149149
);
150150
for (const jsFile of jsFiles) {
151-
const tsFile = replaceExtension(jsFile, '.tsx');
151+
const tsFile = replaceExtension(jsFile, '.ts');
152+
const tsxFile = replaceExtension(jsFile, '.tsx');
152153
// If the TypeScript version already existed in the template, just
153154
// remove the JavaScript version
154-
if (fs.existsSync(tsFile)) {
155+
if (fs.existsSync(tsFile) || fs.existsSync(tsxFile)) {
155156
fs.removeSync(jsFile);
156157
} else {
157-
fs.renameSync(jsFile, tsFile);
158+
fs.renameSync(jsFile, tsxFile);
158159
}
159160
}
160161
} else {

0 commit comments

Comments
 (0)