From ed9c151933f584196a9d9367e59f7ccea876e04b Mon Sep 17 00:00:00 2001 From: nirholas Date: Tue, 31 Mar 2026 11:13:22 +0000 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20Add=20TypeScript=20configuration=20?= =?UTF-8?q?and=20local=20type=20declarations=20for=20build=20scripts?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- scripts/tsconfig.json | 15 ++++++++ scripts/types.d.ts | 86 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 101 insertions(+) create mode 100644 scripts/types.d.ts diff --git a/scripts/tsconfig.json b/scripts/tsconfig.json index e69de29..d0e97b6 100644 --- a/scripts/tsconfig.json +++ b/scripts/tsconfig.json @@ -0,0 +1,15 @@ +{ + "compilerOptions": { + "target": "ESNext", + "module": "ESNext", + "moduleResolution": "bundler", + "esModuleInterop": true, + "strict": true, + "skipLibCheck": true, + "noEmit": true, + "resolveJsonModule": true, + "isolatedModules": true, + "types": ["node"] + }, + "include": ["./**/*.ts", "./types.d.ts"] +} diff --git a/scripts/types.d.ts b/scripts/types.d.ts new file mode 100644 index 0000000..80ccad7 --- /dev/null +++ b/scripts/types.d.ts @@ -0,0 +1,86 @@ +// Local type declarations for scripts/ — avoids depending on installed packages +// for type checking in build scripts. + +// ── esbuild (minimal surface used by build-bundle.ts) ── +declare module 'esbuild' { + export interface Plugin { + name: string + setup(build: PluginBuild): void + } + + export interface PluginBuild { + onResolve( + options: { filter: RegExp }, + callback: (args: OnResolveArgs) => OnResolveResult | undefined | null, + ): void + } + + export interface OnResolveArgs { + path: string + importer: string + namespace: string + resolveDir: string + kind: string + pluginData: unknown + } + + export interface OnResolveResult { + path?: string + external?: boolean + namespace?: string + pluginData?: unknown + } + + export interface BuildOptions { + entryPoints?: string[] + bundle?: boolean + platform?: string + target?: string[] + format?: string + outdir?: string + outExtension?: Record + splitting?: boolean + plugins?: Plugin[] + tsconfig?: string + alias?: Record + external?: string[] + jsx?: string + sourcemap?: boolean | string + minify?: boolean + treeShaking?: boolean + define?: Record + banner?: Record + resolveExtensions?: string[] + logLevel?: string + metafile?: boolean + [key: string]: unknown + } + + export interface Metafile { + inputs: Record + outputs: Record + } + + export interface BuildResult { + errors: { text: string }[] + warnings: { text: string }[] + metafile?: Metafile + } + + export interface BuildContext { + watch(): Promise + serve(options?: unknown): Promise + rebuild(): Promise + dispose(): Promise + } + + export function build(options: BuildOptions): Promise + export function context(options: BuildOptions): Promise + export function analyzeMetafile(metafile: Metafile, options?: { verbose?: boolean }): Promise +} + +// ── Bun's ImportMeta extensions ── +interface ImportMeta { + dir: string + dirname: string +}