Skip to content

Commit f1cdce3

Browse files
authored
feat: use solution-style tsconfigs for more accurate type checking (vuejs#40)
1 parent b5851bc commit f1cdce3

File tree

13 files changed

+890
-617
lines changed

13 files changed

+890
-617
lines changed

index.js

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -286,8 +286,18 @@ async function init() {
286286
}
287287
if (needsTypeScript) {
288288
render('config/typescript')
289+
290+
// Render tsconfigs
291+
render('tsconfig/base')
292+
if (needsCypress) {
293+
render('tsconfig/cypress')
294+
}
295+
if (needsVitest) {
296+
render('tsconfig/vitest')
297+
}
289298
}
290299

300+
// Render ESLint config
291301
if (needsEslint) {
292302
renderEslint(root, { needsTypeScript, needsCypress, needsCypressCT, needsPrettier })
293303
}
@@ -316,13 +326,15 @@ async function init() {
316326
// If that's not possible, we put `.ts` version alongside the `.js` one in the templates.
317327
// So after all the templates are rendered, we need to clean up the redundant files.
318328
// (Currently it's only `cypress/plugin/index.ts`, but we might add more in the future.)
329+
// (Or, we might completely get rid of the plugins folder as Cypress 10 supports `cypress.config.ts`)
319330

320331
if (needsTypeScript) {
321332
// Convert the JavaScript template to the TypeScript
322333
// Check all the remaining `.js` files:
323334
// - If the corresponding TypeScript version already exists, remove the `.js` version.
324335
// - Otherwise, rename the `.js` file to `.ts`
325-
// rename jsconfig.json to tsconfig.json
336+
// Remove `jsconfig.json`, because we already hav tsconfig.json
337+
// `jsconfig.json` is not reused, because we use solution-style `tsconfig`s, which are much more complicated.
326338
preOrderDirectoryTraverse(
327339
root,
328340
() => {},
@@ -335,7 +347,7 @@ async function init() {
335347
fs.renameSync(filepath, tsFilePath)
336348
}
337349
} else if (path.basename(filepath) === 'jsconfig.json') {
338-
fs.renameSync(filepath, filepath.replace(/jsconfig\.json$/, 'tsconfig.json'))
350+
fs.unlinkSync(filepath)
339351
}
340352
}
341353
)

0 commit comments

Comments
 (0)