Skip to content

Commit

Permalink
chore(ui): use the solution tsconfig pattern
Browse files Browse the repository at this point in the history
Type checking is currently not evaluated for referenced files. In order
to make it evaluate, we have to use `--build`. However, this cannot be
used with `--noEmit` and so will emit compiled files unless we use the
solution tsconfig pattern.

See
- microsoft/TypeScript#53979
- vitejs/vite#15913

See also
- https://www.typescriptlang.org/docs/handbook/project-references.html#overall-structure
- vitejs/vite#17774
  • Loading branch information
aentwist committed Aug 25, 2024
1 parent 404ab18 commit 62aa3fc
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 33 deletions.
2 changes: 1 addition & 1 deletion ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"make": "electron-forge make",
"lint": "eslint --fix --ext .ts,.tsx --report-unused-disable-directives --max-warnings 0 .",
"format": "prettier --write .",
"type-check": "tsc --noEmit"
"type-check": "tsc --build"
},
"devDependencies": {
"@electron-forge/cli": "^7.4.0",
Expand Down
32 changes: 32 additions & 0 deletions ui/tsconfig.app.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{
"compilerOptions": {
"target": "ES2021",
"useDefineForClassFields": true,
"lib": ["ES2021", "DOM", "DOM.Iterable"],
"module": "commonjs",
"skipLibCheck": true,
"esModuleInterop": true,
"noImplicitAny": true,
"sourceMap": true,
"baseUrl": ".",
"outDir": "dist",

/* Bundler mode */
"moduleResolution": "node",
// "allowImportingTsExtensions": true,
"resolveJsonModule": true,
// "isolatedModules": true,
"noEmit": true,
"jsx": "react-jsx",
// https://github.com/emotion-js/emotion/issues/1249#issuecomment-828088254
"jsxImportSource": "@emotion/react",
"types": ["vitest/globals"],

/* Linting */
"strict": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"noFallthroughCasesInSwitch": true
},
"include": ["src/**/*"]
}
36 changes: 5 additions & 31 deletions ui/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,33 +1,7 @@
{
"compilerOptions": {
"target": "ES2021",
"useDefineForClassFields": true,
"lib": ["ES2021", "DOM", "DOM.Iterable"],
"module": "commonjs",
"skipLibCheck": true,
"esModuleInterop": true,
"noImplicitAny": true,
"sourceMap": true,
"baseUrl": ".",
"outDir": "dist",

/* Bundler mode */
"moduleResolution": "node",
// "allowImportingTsExtensions": true,
"resolveJsonModule": true,
// "isolatedModules": true,
"noEmit": true,
"jsx": "react-jsx",
// https://github.com/emotion-js/emotion/issues/1249#issuecomment-828088254
"jsxImportSource": "@emotion/react",
"types": ["vitest/globals"],

/* Linting */
"strict": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"noFallthroughCasesInSwitch": true
},
"include": ["src"],
"references": [{ "path": "./tsconfig.node.json" }]
"files": [],
"references": [
{ "path": "./tsconfig.app.json" },
{ "path": "./tsconfig.node.json" }
]
}
1 change: 0 additions & 1 deletion ui/tsconfig.node.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
{
"compilerOptions": {
"composite": true,
"skipLibCheck": true,
"module": "ESNext",
"moduleResolution": "bundler",
Expand Down

0 comments on commit 62aa3fc

Please sign in to comment.