Skip to content
Latchkey

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

  1. 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

  1. 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

Tired of flaky CI? Latchkey auto-heals failed jobs and retries them for you. Start free →