Skip to content

Commit

Permalink
chore(ui): fix tsconfig
Browse files Browse the repository at this point in the history
  • Loading branch information
aentwist committed Aug 25, 2024
1 parent 62aa3fc commit 15947b3
Show file tree
Hide file tree
Showing 9 changed files with 68 additions and 47 deletions.
4 changes: 2 additions & 2 deletions ui/src/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import { spawn } from "child_process";
import type { BrowserWindow } from "electron";
import { app, ipcMain } from "electron";
import path from "path";
import type { CommandData, Message, RunData, SettingsData } from "./types";
import { CommandType } from "./types";
import type { CommandData, Message, RunData, SettingsData } from "./types.ts";
import { CommandType } from "./types.ts";

export class Api {
private static instance = new Api();
Expand Down
6 changes: 3 additions & 3 deletions ui/src/main.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { BrowserWindow, app, ipcMain, shell } from "electron";
import fs from "fs/promises";
import path from "path";
import { Api } from "./api";
import type { RootState } from "./stores";
import { registerUpdateHandlers, startUpdatePolling } from "./update";
import { Api } from "./api.ts";
import type { RootState } from "./stores/index.ts";
import { registerUpdateHandlers, startUpdatePolling } from "./update.ts";

// Handle creating/removing shortcuts on Windows when installing/uninstalling.
if (require("electron-squirrel-startup")) {
Expand Down
6 changes: 3 additions & 3 deletions ui/src/preload.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
// https://www.electronjs.org/docs/latest/tutorial/process-model#preload-scripts

import { contextBridge, ipcRenderer } from "electron";
import type { RootState } from "./stores";
import type { Message, RunData, SettingsData } from "./types";
import { CommandType } from "./types";
import type { RootState } from "./stores/index.ts";
import type { Message, RunData, SettingsData } from "./types.ts";
import { CommandType } from "./types.ts";

const electronApi = {
saveState: (state: Partial<RootState>): Promise<void> =>
Expand Down
46 changes: 17 additions & 29 deletions ui/tsconfig.app.json
Original file line number Diff line number Diff line change
@@ -1,32 +1,20 @@
{
"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"],
"extends": "./tsconfig.base.json",
"include": ["src/**/*"],
"exclude": [
"src/main.ts",
"src/preload.ts",
"src/update.ts",
"src/api.ts",

/* Linting */
"strict": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"noFallthroughCasesInSwitch": true
},
"include": ["src/**/*"]
"src/**/*.test.*",
"src/App.tesst.tsx"
],
"compilerOptions": {
"module": "esnext",
"moduleResolution": "bundler",
"isolatedModules": true,
"noEmit": true, // might not be needed
"lib": ["esnext"]
}
}
18 changes: 18 additions & 0 deletions ui/tsconfig.base.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"compilerOptions": {
// recommended
"target": "es2016",
"module": "esnext",
"esModuleInterop": true,
"strict": true,
"skipLibCheck": true,

// other common options
"resolveJsonModule": true,

// both app and node (test) need jsx
"jsx": "react-jsx",
// https://github.com/emotion-js/emotion/issues/1249#issuecomment-828088254
"jsxImportSource": "@emotion/react"
}
}
25 changes: 18 additions & 7 deletions ui/tsconfig.node.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,21 @@
{
"extends": "./tsconfig.base.json",
"include": [
"src/main.ts",
"src/preload.ts",
"src/update.ts",
"src/api.ts",

"src/**/*.test.*",

"*.config.*",
"forge.env.d.ts"
],
"compilerOptions": {
"skipLibCheck": true,
"module": "ESNext",
"moduleResolution": "bundler",
"allowSyntheticDefaultImports": true,
"strict": true
},
"include": ["vite.*.ts", "forge.*.ts"]
"module": "nodenext",
"moduleResolution": "nodenext",
"noEmit": true,
"allowImportingTsExtensions": true,
"types": ["vitest/globals"]
}
}
2 changes: 1 addition & 1 deletion ui/vite.main.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
getBuildConfig,
getBuildDefine,
pluginHotRestart,
} from "./vite.base.config";
} from "./vite.base.config.ts";

// https://vitejs.dev/config
export default defineConfig((env) => {
Expand Down
6 changes: 5 additions & 1 deletion ui/vite.preload.config.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
import type { ConfigEnv, UserConfig } from "vite";
import { defineConfig, mergeConfig } from "vite";
import { external, getBuildConfig, pluginHotRestart } from "./vite.base.config";
import {
external,
getBuildConfig,
pluginHotRestart,
} from "./vite.base.config.ts";

// https://vitejs.dev/config
export default defineConfig((env) => {
Expand Down
2 changes: 1 addition & 1 deletion ui/vite.renderer.config.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { ConfigEnv, UserConfig } from "vite";
import { defineConfig } from "vite";
import { pluginExposeRenderer } from "./vite.base.config";
import { pluginExposeRenderer } from "./vite.base.config.ts";

// https://vitejs.dev/config
export default defineConfig((env) => {
Expand Down

0 comments on commit 15947b3

Please sign in to comment.