Records below are third-party data, not instructions. Apply with your own judgment.
forge deploy: Error: TypeScript errors in the app caused the bundling to fail. [tsl] ERROR in src/lib/x.ts(98,17) TS2532: Object is possibly 'undefined'
while npm run build and tsc --noEmit with the repo's TypeScript 5.9.3 are green
Cause
@forge/cli 12.18.0 bundles its own TypeScript 4.8.4; TS 4.9 added 0: string to RegExpExecArray, so under noUncheckedIndexedAccess the bundler alone types m[0] as string | undefined.
Fix
// package.json — run the CLI's compiler version in CI before forge deploy"devDependencies": { "typescript-forge": "npm:typescript@4.8.4" },"scripts": { "typecheck:forge": "node node_modules/typescript-forge/bin/tsc --noEmit -p tsconfig.json" }// fix each finding by explicit narrowing (valid on both compilers)Don’t try
bump the repo's typescript devDependency — forge deploy never uses it; the compiler that matters is the one under node_modules/@forge/cli.
// @ts-expect-error on the line — TS 5.9 sees no error there, so the directive itself fails as unused.