Unfuck tsconfigs + VS Code + eslint + tsc, fix type errors

This commit is contained in:
Mario Zechner 2025-06-24 01:51:34 +02:00
parent 288a3197d2
commit 498eb4f3fc
10 changed files with 83 additions and 67 deletions

View file

@ -14,7 +14,7 @@ module.exports = tseslint.config(
files: ['src/**/*.ts', 'src/**/*.tsx'],
languageOptions: {
parserOptions: {
project: ['./tsconfig.json', './tsconfig.client.json', './tsconfig.sw.json', './tsconfig.test.json'],
project: ['./tsconfig.server.json', './tsconfig.client.json', './tsconfig.sw.json', './tsconfig.test.json'],
tsconfigRootDir: __dirname,
},
},

View file

@ -11,7 +11,7 @@
"build:ci": "node scripts/build-ci.js",
"lint": "eslint 'src/**/*.{ts,tsx}'",
"lint:fix": "eslint 'src/**/*.{ts,tsx}' --fix",
"typecheck": "tsc --noEmit && tsc --noEmit --project tsconfig.client.json && tsc --noEmit --project tsconfig.sw.json",
"typecheck": "tsc --noEmit --project tsconfig.server.json && tsc --noEmit --project tsconfig.client.json && tsc --noEmit --project tsconfig.sw.json",
"test": "vitest",
"test:ci": "vitest run --reporter=verbose",
"format": "prettier --write 'src/**/*.{ts,tsx,js,jsx,json,css,md}'",

View file

@ -81,7 +81,7 @@ export function createSessionRoutes(config: SessionRoutesConfig): Router {
});
if (response.ok) {
const remoteSessions = await response.json();
const remoteSessions = (await response.json()) as Session[];
logger.debug(`got ${remoteSessions.length} sessions from remote ${remote.name}`);
// Track session IDs for this remote
@ -169,7 +169,7 @@ export function createSessionRoutes(config: SessionRoutesConfig): Router {
return res.status(response.status).json(error);
}
const result = await response.json();
const result = (await response.json()) as { sessionId: string };
logger.debug(`remote session creation took ${Date.now() - startTime}ms`);
// Track the session in the remote's sessionIds
@ -543,7 +543,7 @@ export function createSessionRoutes(config: SessionRoutesConfig): Router {
});
if (response.ok) {
const result = await response.json();
const result = (await response.json()) as { cleanedSessions: string[] };
const cleanedSessionIds = result.cleanedSessions || [];
const cleanedCount = cleanedSessionIds.length;
totalCleaned += cleanedCount;

View file

@ -56,7 +56,9 @@ export class HQClient {
});
if (!response.ok) {
const errorBody = await response.json().catch(() => ({ error: response.statusText }));
const errorBody = (await response.json().catch(() => ({ error: response.statusText }))) as {
error: string;
};
logger.debug(`registration failed with status ${response.status}`, errorBody);
throw new Error(`Registration failed: ${errorBody.error || response.statusText}`);
}

18
web/tsconfig.base.json Normal file
View file

@ -0,0 +1,18 @@
{
"compilerOptions": {
"target": "ES2020",
"lib": ["ES2020"],
"strict": true,
"esModuleInterop": true,
"skipLibCheck": true,
"forceConsistentCasingInFileNames": true,
"moduleResolution": "node",
"allowSyntheticDefaultImports": true,
"resolveJsonModule": true,
"sourceMap": true,
"experimentalDecorators": true,
"emitDecoratorMetadata": true,
"useDefineForClassFields": false,
"typeRoots": ["./node_modules/@types"]
}
}

View file

@ -1,32 +1,26 @@
{
"extends": "./tsconfig.base.json",
"compilerOptions": {
"target": "ES2020",
"module": "ES2020",
"lib": ["ES2020", "dom", "dom.iterable"],
"outDir": "./public",
"rootDir": "./src",
"strict": true,
"esModuleInterop": true,
"skipLibCheck": true,
"forceConsistentCasingInFileNames": true,
"moduleResolution": "node",
"allowSyntheticDefaultImports": true,
"sourceMap": true,
"inlineSourceMap": false,
"inlineSources": true,
"declaration": false,
"experimentalDecorators": true,
"emitDecoratorMetadata": true,
"useDefineForClassFields": false,
"declaration": true,
"composite": true
},
"include": [
"src/client/**/*"
"src/client/**/*",
"src/shared/**/*",
"src/types/**/*"
],
"exclude": [
"node_modules",
"dist",
"src/cli.ts",
"src/client/sw.ts"
"src/client/sw.ts",
"src/**/*.test.ts",
"src/**/*.spec.ts"
]
}

View file

@ -1,37 +1,8 @@
{
"compilerOptions": {
"target": "ES2020",
"module": "CommonJS",
"lib": ["ES2020", "dom"],
"outDir": "./dist",
"rootDir": "./src",
"strict": true,
"esModuleInterop": true,
"skipLibCheck": true,
"forceConsistentCasingInFileNames": true,
"moduleResolution": "node",
"allowSyntheticDefaultImports": true,
"resolveJsonModule": true,
"sourceMap": true,
"declaration": false,
"experimentalDecorators": true,
"emitDecoratorMetadata": true,
"useDefineForClassFields": false,
"typeRoots": ["./node_modules/@types"]
},
"include": [
"src/server/**/*",
"src/shared/**/*",
"src/types/**/*",
"src/cli.ts"
],
"exclude": [
"node_modules",
"dist",
"public",
"src/client/**/*"
],
"files": [],
"references": [
{ "path": "./tsconfig.server.json" },
{ "path": "./tsconfig.client.json" },
{ "path": "./tsconfig.sw.json" }
]
}

27
web/tsconfig.server.json Normal file
View file

@ -0,0 +1,27 @@
{
"extends": "./tsconfig.base.json",
"compilerOptions": {
"module": "CommonJS",
"lib": ["ES2020"],
"outDir": "./dist",
"rootDir": "./src",
"declaration": true,
"types": ["node"],
"composite": true
},
"include": [
"src/server/**/*",
"src/shared/**/*",
"src/types/**/*",
"src/cli.ts",
"src/index.ts"
],
"exclude": [
"node_modules",
"dist",
"public",
"src/client/**/*",
"src/**/*.test.ts",
"src/**/*.spec.ts"
]
}

View file

@ -1,25 +1,18 @@
{
"extends": "./tsconfig.base.json",
"compilerOptions": {
"target": "ES2020",
"module": "ES2020",
"lib": ["ES2020", "webworker", "webworker.iterable"],
"outDir": "./public",
"rootDir": "./src",
"strict": true,
"esModuleInterop": true,
"skipLibCheck": true,
"forceConsistentCasingInFileNames": true,
"moduleResolution": "node",
"allowSyntheticDefaultImports": true,
"sourceMap": true,
"inlineSourceMap": false,
"inlineSources": true,
"declaration": false,
"experimentalDecorators": true,
"useDefineForClassFields": false
"declaration": true
},
"include": [
"src/client/sw.ts"
"src/client/sw.ts",
"src/shared/**/*",
"src/types/**/*"
],
"exclude": [
"node_modules",

View file

@ -1,11 +1,22 @@
{
"extends": "./tsconfig.json",
"extends": "./tsconfig.base.json",
"compilerOptions": {
"types": ["vitest/globals"]
"module": "ES2020",
"lib": ["ES2020", "dom"],
"types": ["vitest/globals", "node"]
},
"include": [
"src/**/*.test.ts",
"src/**/*.spec.ts",
"src/test/**/*"
"src/test/**/*",
"src/server/**/*",
"src/client/**/*",
"src/shared/**/*",
"src/types/**/*"
],
"exclude": [
"node_modules",
"dist",
"public"
]
}