-
-
Notifications
You must be signed in to change notification settings - Fork 303
Description
When a tsconfig.json extends a base config that uses ${configDir} (the TypeScript 5.5 path variable) in outDir, include, or exclude, XO reports spurious errors like:
Unsafe assignment of an error typed valueUnsafe call of a type that could not be resolved
Replacing ${configDir} with ../ in the base tsconfig.json makes the errors go away, which indicates XO fails to resolve ${configDir} properly.
Reproduction
https://github.com/alejandrohdezma/xo-repro
The repo has the following setup:
tsconfig.json — extends a base config:
{
"extends": "./remote_lib/tsconfig.json"
}remote_lib/tsconfig.json — base config using ${configDir}:
{
"compilerOptions": {
"outDir": "${configDir}/dist",
"resolveJsonModule": true,
"skipLibCheck": true,
"strict": true
},
"include": ["${configDir}/src/**/*.ts"],
"exclude": ["${configDir}/node_modules", "${configDir}/dist", "${configDir}/tests"]
}src/config.ts — simple file using zod:
import {z} from 'zod'
export const Config = z.object({
something: z.array(z.string()),
other: z.object({
something: z.string(),
}),
})
export type Config = z.infer<typeof Config>Steps:
npm installnpm run build(passes correctly)npm run check(produces false errors)- Replace
${configDir}with../inremote_lib/tsconfig.json npm run check(no errors)
Context
I believe this is a regression — XO 0.60.0 apparently handled this correctly. ${configDir} is important for shared/company-wide base tsconfig.json files distributed as packages, where relative paths like ../ don't work reliably since the consuming project's directory depth is unknown. Without ${configDir}, every consuming project would need to override outDir, include, and exclude.
Workaround
Currently I'm solving this by pinning XO version to 0.60.0.