From 3353f7e0083a5dac4b0938a2038d3c885904cc2b Mon Sep 17 00:00:00 2001 From: Phil Bates Date: Sat, 24 Feb 2024 10:25:40 +0000 Subject: [PATCH] tsconfig: Introduce new tsconfig.app.json The change in 2aa6462e9 is resulting in a vite.config.js and vite.config.d.ts being generated which we don't want. The work around, to be able to have type checking of both src files and vite.config.ts during build is to create a dedicated tsconfig.app.json and tsconfig.node.json. See: * https://github.com/vitejs/vite/pull/15913 * https://github.com/vuejs/create-vue/blob/f75fd9813a624b8e44b012608335721901aba00b/template/tsconfig/base/tsconfig.json --- .eslintignore | 1 + .eslintrc.cjs | 2 +- .prettierignore | 1 + tsconfig.app.json | 29 +++++++++++++++++++++++++++++ tsconfig.json | 34 ++++++++-------------------------- tsconfig.node.json | 1 + 6 files changed, 41 insertions(+), 27 deletions(-) create mode 100644 tsconfig.app.json diff --git a/.eslintignore b/.eslintignore index 31f7195..2b51543 100644 --- a/.eslintignore +++ b/.eslintignore @@ -4,6 +4,7 @@ # Except...: !resources/ !package.json +!tsconfig.app.json !tsconfig.json !tsconfig.node.json !vite.config.ts diff --git a/.eslintrc.cjs b/.eslintrc.cjs index 441d5a3..e95b02b 100644 --- a/.eslintrc.cjs +++ b/.eslintrc.cjs @@ -11,7 +11,7 @@ module.exports = { ], parser: "@typescript-eslint/parser", parserOptions: { - project: ["./tsconfig.json", "./tsconfig.node.json"], + project: ["./tsconfig.json", "./tsconfig.app.json", "./tsconfig.node.json"], tsconfigRootDir: __dirname, }, plugins: ["import"], diff --git a/.prettierignore b/.prettierignore index 6d5b68f..5df7e04 100644 --- a/.prettierignore +++ b/.prettierignore @@ -5,6 +5,7 @@ !resources/ !.eslintrc.cjs !package.json +!tsconfig.app.json !tsconfig.json !tsconfig.node.json !vite.config.ts diff --git a/tsconfig.app.json b/tsconfig.app.json new file mode 100644 index 0000000..d8ede9b --- /dev/null +++ b/tsconfig.app.json @@ -0,0 +1,29 @@ +{ + "compilerOptions": { + "composite": true, + "target": "ESNext", + "useDefineForClassFields": true, + "module": "ESNext", + "lib": ["ESNext", "DOM", "DOM.Iterable"], + "skipLibCheck": true, + + /* Bundler mode */ + "moduleResolution": "bundler", + "allowImportingTsExtensions": true, + "resolveJsonModule": true, + "isolatedModules": true, + "noEmit": true, + + /* Absolute imports */ + "paths": { + "@/*": ["./resources/js/*"] + }, + + /* Linting */ + "strict": true, + "noUnusedLocals": true, + "noUnusedParameters": true, + "noFallthroughCasesInSwitch": true + }, + "include": ["resources/js"] +} diff --git a/tsconfig.json b/tsconfig.json index 48e2d0a..ea9d0cd 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,29 +1,11 @@ { - "compilerOptions": { - "target": "ESNext", - "useDefineForClassFields": true, - "module": "ESNext", - "lib": ["ESNext", "DOM", "DOM.Iterable"], - "skipLibCheck": true, - - /* Bundler mode */ - "moduleResolution": "bundler", - "allowImportingTsExtensions": true, - "resolveJsonModule": true, - "isolatedModules": true, - "noEmit": true, - - /* Absolute imports */ - "paths": { - "@/*": ["./resources/js/*"] + "files": [], + "references": [ + { + "path": "./tsconfig.app.json" }, - - /* Linting */ - "strict": true, - "noUnusedLocals": true, - "noUnusedParameters": true, - "noFallthroughCasesInSwitch": true - }, - "include": ["resources/js"], - "references": [{ "path": "./tsconfig.node.json" }] + { + "path": "./tsconfig.node.json" + } + ] } diff --git a/tsconfig.node.json b/tsconfig.node.json index 97ede7e..911f07c 100644 --- a/tsconfig.node.json +++ b/tsconfig.node.json @@ -4,6 +4,7 @@ "skipLibCheck": true, "module": "ESNext", "moduleResolution": "bundler", + "noEmit": true, "allowSyntheticDefaultImports": true, "strict": true },