From f6680375824337148a70cf0851b837650351c058 Mon Sep 17 00:00:00 2001 From: mitchell Date: Tue, 26 May 2026 19:27:41 -0400 Subject: [PATCH] chore(config): pin @types/bun, tighten TypeScript strictness, and refactor config logic - Pin `@types/bun` to `^1.3.14` for reproducible builds instead of using `latest` - Update `tsconfig.json` with stricter type-checking flags and reorganize compiler options - Refactor `initConfig` to DRY up the model default logic and add a null guard before process exit --- package.json | 2 +- pnpm-lock.yaml | 2 +- src/config/index.ts | 9 +++++--- testRender.ts | 2 +- tsconfig.json | 50 +++++++++++++++++++++++++++------------------ 5 files changed, 39 insertions(+), 26 deletions(-) diff --git a/package.json b/package.json index 63eb70c..cd6a5ce 100644 --- a/package.json +++ b/package.json @@ -18,7 +18,7 @@ }, "devDependencies": { "@biomejs/biome": "2.4.12", - "@types/bun": "latest", + "@types/bun": "^1.3.14", "esbuild": "0.28.0" }, "peerDependencies": { diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 9cacba1..874a0f3 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -55,7 +55,7 @@ importers: specifier: 2.4.12 version: 2.4.12 '@types/bun': - specifier: latest + specifier: ^1.3.14 version: 1.3.14 esbuild: specifier: 0.28.0 diff --git a/src/config/index.ts b/src/config/index.ts index 2ddabcc..9e23618 100644 --- a/src/config/index.ts +++ b/src/config/index.ts @@ -23,17 +23,20 @@ export async function initConfig(old: AppConfig | null): Promise { if (isCancel(baseURL)) process.exit(1); const models = await getModels(baseURL); + const initialValue = models.includes(old?.model ?? "") + ? old?.model + : models[0]; const model = await autocomplete({ message: "Choose a default model:", - initialValue: models.includes(old?.model ?? "") ? old?.model : models[0], - placeholder: models.includes(old?.model ?? "") ? old?.model : models[0], + initialValue, + placeholder: initialValue ?? "Start typing...", options: models.map((model) => ({ value: model })), validate: (value) => models.includes(typeof value === "string" ? value : "") ? undefined : `Unable to find model "${value}"`, }); - if (isCancel(model)) process.exit(1); + if (!model || isCancel(model)) process.exit(1); const config = { baseURL, model } satisfies AppConfig; diff --git a/testRender.ts b/testRender.ts index 6373337..4fecfd9 100644 --- a/testRender.ts +++ b/testRender.ts @@ -1,4 +1,4 @@ -import { renderMarkdown } from "./src/render/markdown.ts"; +import { renderMarkdown } from "./src/render/markdown"; const text = await Bun.file("README.md").text(); diff --git a/tsconfig.json b/tsconfig.json index bfa0fea..edeab3e 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,29 +1,39 @@ { + // Visit https://aka.ms/tsconfig to read more about this file "compilerOptions": { - // Environment setup & latest features - "lib": ["ESNext"], - "target": "ESNext", - "module": "Preserve", - "moduleDetection": "force", - "jsx": "react-jsx", - "allowJs": true, - - // Bundler mode + // Environment Settings + // See also https://aka.ms/tsconfig/module + "module": "esnext", + "target": "esnext", "moduleResolution": "bundler", - "allowImportingTsExtensions": true, - "verbatimModuleSyntax": true, + "esModuleInterop": true, "noEmit": true, + // For nodejs: + "lib": ["esnext"], + "types": ["bun"], + // and npm install -D @types/node - // Best practices - "strict": true, - "skipLibCheck": true, - "noFallthroughCasesInSwitch": true, + // Stricter Typechecking Options "noUncheckedIndexedAccess": true, - "noImplicitOverride": true, + "exactOptionalPropertyTypes": true, - // Some stricter flags (disabled by default) - "noUnusedLocals": false, - "noUnusedParameters": false, - "noPropertyAccessFromIndexSignature": false + // Style Options + "noImplicitReturns": true, + "noImplicitOverride": true, + "noUnusedLocals": true, + "noUnusedParameters": true, + "noFallthroughCasesInSwitch": true, + "noPropertyAccessFromIndexSignature": true, + + // Recommended Options + "strict": true, + "jsx": "react-jsx", + //"allowImportingTsExtensions": true, + "allowArbitraryExtensions": true, + "verbatimModuleSyntax": true, + "isolatedModules": true, + "noUncheckedSideEffectImports": true, + "moduleDetection": "force", + "skipLibCheck": true } }