TS18046: Value is of type unknown - in CI
A value typed unknown (commonly a caught error under useUnknownInCatchVariables) was used without narrowing.
What this error means
Type-checking fails with TS18046 at a member access or operation on an unknown value.
tsc
src/catch.ts(4,21): error TS18046: 'err' is of type 'unknown'.Common causes
How to fix it
Narrow before use
- Use instanceof or a type guard to refine unknown to a concrete type
ts
try {} catch (err) {
if (err instanceof Error) console.log(err.message)
}Validate parsed data
- Run unknown input through a schema/guard before treating it as a known shape
How to prevent it
- Keep useUnknownInCatchVariables on and always narrow unknown with guards rather than casting.
Related guides
TS2339: Property does not exist on type - in CIFix "error TS2339: Property 'x' does not exist on type 'Y'" when tsc runs in CI - accessing a member the type…
TS18047: Value is possibly null - in CIFix "error TS18047: 'x' is possibly 'null'" when tsc runs in CI under strictNullChecks - guard the value befo…