Skip to main content

TypeScript error codes, explained

One page per error: what the compiler actually means, a reproduction you can paste, and the realistic fixes — including when a fix is the wrong call.

TS18046
'x' is of type 'unknown'.

Same complaint as TS2571, phrased for a named variable — most often a catch-clause error.

TS18047
'x' is possibly 'null'.

The value can be null, and you used it without checking first.

TS18048
'x' is possibly 'undefined'.

Same as TS2531, but for undefined.

TS2304
Cannot find name 'x'.

TypeScript has never heard of this identifier.

TS2307
Cannot find module 'x' or its corresponding type declarations.

TypeScript can't resolve an import — the package, the path, or the types are missing.

TS2322
Type 'X' is not assignable to type 'Y'.

You're putting a value somewhere its type doesn't fit.

TS2339
Property 'x' does not exist on type 'Y'.

You're reading a property TypeScript doesn't believe is there.

TS2345
Argument of type 'X' is not assignable to parameter of type 'Y'.

You're passing the wrong type into a function.

TS2349
This expression is not callable.

You put () after something that is not a function.

TS2367
This comparison appears to be unintentional because the types 'X' and 'Y' have no overlap.

You compared two values that can never be equal, so the comparison is always false.

TS2451
Cannot redeclare block-scoped variable 'x'.

The same let/const name is declared twice in one scope — often across files you didn't expect to share one.

TS2454
Variable 'x' is used before being assigned.

TypeScript can see a path through your code where the variable is still empty when you read it.

TS2531
Object is possibly 'null'.

You're using a value that TypeScript knows can be null.

TS2532
Object is possibly 'undefined'.

You're accessing something on a value that may be undefined at that point.

TS2538
Type 'X' cannot be used as an index type.

You indexed an object with something that is not a string, number or symbol.

TS2540
Cannot assign to 'x' because it is a read-only property.

The property is marked readonly, so it can only be set when the object is created.

TS2551
Property 'x' does not exist on type 'Y'. Did you mean 'z'?

TS2339 with a spelling suggestion — you probably have a typo.

TS2554
Expected N arguments, but got M.

The call site and the function signature disagree about how many arguments there are.

TS2564
Property 'x' has no initializer and is not definitely assigned in the constructor.

A class field has a type but nothing ever guarantees it gets a value.

TS2571
Object is of type 'unknown'.

You're using a value typed unknown without proving what it is first.

TS2578
Unused '@ts-expect-error' directive.

The error you were suppressing is gone — the directive now has nothing to suppress, and that's the feature working.

TS2588
Cannot assign to 'x' because it is a constant.

You're reassigning a const.

TS2739
Type 'X' is missing the following properties from type 'Y': a, b, c

An object literal doesn't have all the properties the target type requires.

TS2741
Property 'x' is missing in type 'A' but required in type 'B'.

The object you supplied lacks one required property of the target type.

TS2769
No overload matches this call.

The function has several accepted signatures and your arguments fit none of them.

TS2790
The operand of a 'delete' operator must be optional.

You tried to delete a required property. Deleting it would leave the object not matching its own type.

TS2792
Cannot find module 'x'. Did you mean to set the 'moduleResolution' option to 'nodenext', or to add aliases to the 'paths' option?

The module exists, but TypeScript is looking for it the wrong way — this is a tsconfig problem, not a missing package.

TS6133
'x' is declared but its value is never read.

You declared something and never used it. This is a lint-style hint, not a type error.

TS6196
'X' is declared but never used.

The type-level twin of TS6133 — an interface, type alias or enum that nothing references.

TS7006
Parameter 'x' implicitly has an 'any' type.

A function parameter has no type annotation and TypeScript can't infer one.

TS7016
Could not find a declaration file for module 'x'. '.../index.js' implicitly has an 'any' type.

The package exists and runs, but ships no types — so under noImplicitAny the import is an error.

TS7053
Element implicitly has an 'any' type because expression of type 'string' can't be used to index type 'X'.

You're indexing an object with a dynamic string key it doesn't declare.

Looking for a code that is not here? The error decoder covers more codes in brief.