Skip to content
Latchkey

TS2339: Property does not exist on type - in CI

You accessed a property the compiler cannot find on the inferred or declared type.

What this error means

Type-checking fails with TS2339 naming the property and the type it is missing from.

tsc
src/user.ts(12,18): error TS2339: Property 'email' does not exist on type '{ id: number; }'.

Diagnose it: which tsconfig and which compiler?

A TypeScript error that appears only in CI usually means the runner is compiling with a different config or a different compiler version than your editor. Your editor uses the workspace TypeScript and the nearest tsconfig.json; CI uses whatever the lockfile resolved and whatever config the build script names.

Terminal
# what CI will actually use
npx tsc --version
npx tsc --showConfig | head -40

# which files are in the program (a missing include is a common cause)
npx tsc --listFiles | wc -l

# type-check only, no emit, same as most CI gates
npx tsc --noEmit

Common causes

How to fix it

Type the value correctly

  1. Declare an interface that includes the property
  2. Annotate the variable or function return with that type
ts
interface User { id: number; email: string }
const u: User = await getUser()

Narrow a union before access

  1. Use a type guard (in, typeof, discriminant) so the branch has the property
ts
if ('email' in u) console.log(u.email)

Pin the compiler so unrelated updates cannot break the gate

TypeScript adds errors in minor releases. An unpinned compiler turns a routine dependency update into a red build on code nobody touched, which is the most common false alarm in a TypeScript CI pipeline.

package.json
// package.json
{
  "devDependencies": {
    "typescript": "5.6.3"   // exact, not ^5.6.3
  }
}

How to prevent it

  • Type external data with explicit interfaces and narrow unions before member access rather than casting.

Frequently asked questions

How do I fix TS2339: property does not exist on type?
There are 2 fixes depending on which cause you have: type the value correctly and narrow a union before access. Work through them in order, since the first is the most common.
What does TS2339: property does not exist on type actually mean?
Type-checking fails with TS2339 naming the property and the type it is missing from.
How do I stop TS2339: property does not exist on type happening again?
Type external data with explicit interfaces and narrow unions before member access rather than casting.

Related guides

References

Not every red build is your code. Latchkey repairs the ones that are not, on the runner. Start free → 30-day trial · No credit card