TypeScript Errors Reference

Every TypeScript error code explained with real examples and fixes. Search by error code or message to find exactly what you need.

A TypeScript error message has two parts: the code (like TS2345) tells you the category of problem, and the message tells you which types are involved. The reference covers the errors you will actually hit day to day — assignability problems, null and undefined checks, missing properties, and implicit any. Each page explains what the compiler is complaining about, shows the mistake in real code, and walks through the idiomatic fix. When you are done fixing, the best way to stop hitting the same error again is to practice with TypeScript challenges built around it.

59 of 59 errors

TS1002

Fix TS1002: Unterminated String Literal

Unterminated string literal

Syntax ErrorSyntaxStringsParsing
TS1003

Fix TS1003: Identifier Expected

Identifier expected

Syntax ErrorSyntaxParsingImports
TS1005

Fix TS1005: Expected Token

'x' expected

Syntax ErrorSyntaxParsingPunctuation
TS1011

Fix TS1011: Element Access Expression Needs an Argument

An element access expression should take an argument

Syntax ErrorSyntaxParsingType Annotations
TS1100

Fix TS1100: Invalid Use of 'eval' or 'arguments'

Invalid use of 'X' in strict mode

Syntax ErrorStrict ModeSyntaxJavaScript
TS1109

Fix TS1109: Expression Expected

Expression expected

Syntax ErrorSyntaxParsingJSX
TS1128

Fix TS1128: Declaration or Statement Expected

Declaration or statement expected

Syntax ErrorSyntaxParsing
TS1136

Fix TS1136: Property Assignment Expected

Property assignment expected

Syntax ErrorSyntaxObjectsParsing
TS1160

Fix TS1160: Unterminated Template Literal

Unterminated template literal

Syntax ErrorSyntaxTemplate LiteralsStrings
TS1192

Fix TS1192: Module Has No Default Export

Module 'X' has no default export

Syntax ErrorImportsModulesConfig
TS1206

Fix TS1206: Decorators Are Not Valid Here

Decorators are not valid here

Syntax ErrorDecoratorsClassesSyntax
TS2300

Fix TS2300: Duplicate Identifier

Duplicate identifier 'X'

Semantic ErrorDeclarationsConfigType Safety
TS2304

Fix TS2304: Cannot Find Name 'X'

Cannot find name 'X'

Semantic ErrorImportsDeclarationsScope
TS2305

Fix TS2305: Module Has No Exported Member

Module 'X' has no exported member 'Y'

Semantic ErrorModulesImportsType Safety
TS2307

Fix TS2307: Cannot Find Module

Cannot find module 'X' or its corresponding type declarations

Semantic ErrorModulesImportsConfig
TS2314

Fix TS2314: Generic Type Requires Type Arguments

Generic type 'X' requires N type argument(s)

Semantic ErrorGenericsType SafetyInterfaces
TS2322

Fix TS2322: Type Not Assignable

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

Semantic ErrorType SafetyAssignmentType Checking
TS2339

Fix TS2339: Property Does Not Exist on Type

Property 'X' does not exist on type 'Y'

Semantic ErrorProperty AccessType SafetyObjects
TS2344

Fix TS2344: Type Does Not Satisfy the Constraint

Type 'X' does not satisfy the constraint 'Y'

Semantic ErrorGenericsType SafetyUtility Types
TS2345

Fix TS2345: Argument Type Not Assignable to Parameter

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

Semantic ErrorFunction ArgumentsType SafetyParameters
TS2349

Fix TS2349: This Expression Is Not Callable

This expression is not callable

Semantic ErrorType SafetyFunctionsUnion Types
TS2352

Fix TS2352: Type Conversion May Be a Mistake

Conversion of type 'X' to type 'Y' may be a mistake

Semantic ErrorType AssertionsType CastingType Safety
TS2403

Fix TS2403: Subsequent Variable Declarations Must Match

Subsequent variable declarations must have the same type. Variable 'X' must be of type 'Y', but here...

Semantic ErrorDeclarationsConfigGlobals
TS2416

Fix TS2416: Property Not Assignable to Base Type

Property 'X' in type 'Y' is not assignable to the same property in base type 'Z'

Semantic ErrorClassesInheritanceType Safety
TS2451

Fix TS2451: Cannot Redeclare Block-Scoped Variable

Cannot redeclare block-scoped variable 'X'

Semantic ErrorModulesScopeConfig
TS2454

Fix TS2454: Variable Is Used Before Being Assigned

Variable 'X' is used before being assigned

Strict ModeStrict ModeNull SafetyControl Flow
TS2503

Fix TS2503: Cannot Find Namespace

Cannot find namespace 'X'

Semantic ErrorNamespacesDeclarationsConfig
TS2531

Fix TS2531: Object Is Possibly 'null'

Object is possibly 'null'

Strict ModeNull SafetyStrict ModeNull Checks
TS2532

Fix TS2532: Object Is Possibly 'undefined'

Object is possibly 'undefined'

Strict ModeNull SafetyStrict ModeOptional Chaining
TS2551

Fix TS2551: Property Does Not Exist - Did You Mean?

Property 'X' does not exist on type 'Y'. Did you mean 'Z'?

Semantic ErrorTyposProperty AccessSuggestions
TS2554

Fix TS2554: Wrong Number of Arguments

Expected N arguments, but got M

Semantic ErrorFunction ArgumentsArityParameters
TS2556

Fix TS2556: Spread Argument Must Have Tuple Type

A spread argument must either have a tuple type or be passed to a rest parameter

Semantic ErrorSpread OperatorTuplesRest Parameters
TS2564

Fix TS2564: Property Has No Initializer

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

Strict ModeStrict ModeClass PropertiesInitialization
TS2571

Fix TS2571: Object Is of Type 'unknown'

Object is of type 'unknown'

Semantic ErrorUnknown TypeType SafetyType Guards
TS2683

Fix TS2683: 'this' Implicitly Has Type 'any'

'this' implicitly has type 'any' because it does not have a type annotation

Strict Modethis ContextStrict ModenoImplicitThis
TS2688

Fix TS2688: Cannot Find Type Definition File

Cannot find type definition file for 'X'

Compiler ErrorConfigDeclarationsModules
TS2693

Fix TS2693: Only Refers to a Type, Used as a Value

'X' only refers to a type, but is being used as a value here

Semantic ErrorType SafetyInterfacesType Guards
TS2694

Fix TS2694: Namespace Has No Exported Member

Namespace 'X' has no exported member 'Y'

Semantic ErrorNamespacesDeclarationsJSX
TS2740

Fix TS2740: Type 'X' Is Missing Properties from Type 'Y'

Type 'X' is missing the following properties from type 'Y'

Semantic ErrorObject TypesMissing PropertiesInterfaces
TS2742

Fix TS2742: Inferred Type Cannot Be Named

The inferred type of 'X' cannot be named without a reference to 'Y'. This is likely not portable. A ...

Declaration ErrorDeclarationsModulesBuild
TS2769

Fix TS2769: No Overload Matches This Call

No overload matches this call

Semantic ErrorOverloadsFunction CallsType Safety
TS2786

Fix TS2786: Cannot Be Used as a JSX Component

'X' cannot be used as a JSX component

Semantic ErrorJSXReactType Safety
TS5053

Fix TS5053: Option Cannot Be Specified With Option

Option 'X' cannot be specified with option 'Y'

Command ErrorConfigBuildDeclarations
TS5055

Fix TS5055: Cannot Write File, Would Overwrite Input

Cannot write file 'X' because it would overwrite input file

Command ErrorConfigBuildModules
TS6059

Fix TS6059: File Is Not Under 'rootDir'

File 'X' is not under 'rootDir' 'Y'. 'rootDir' is expected to contain all source files

Command ErrorConfigBuildProject References
TS6133

Fix TS6133: Declared but Its Value Is Never Read

'X' is declared but its value is never read

SuggestionConfigCode QualityStrict Mode
TS6305

Fix TS6305: Output File Has Not Been Built From Source File

Output file 'X' has not been built from source file 'Y'

Command ErrorProject ReferencesBuildConfig
TS6307

Fix TS6307: File Is Not Listed Within the Project File List

File 'X' is not listed within the file list of project 'Y'. Projects must list all files or use an '...

Command ErrorConfigBuildModules
TS6385

Fix TS6385: 'X' Is Deprecated

'X' is deprecated

SuggestionDeprecationCode QualitySuggestions
TS7006

Fix TS7006: Parameter Implicitly Has 'any' Type

Parameter 'x' implicitly has an 'any' type

Strict ModeStrict ModeType AnnotationsnoImplicitAny
TS7016

Fix TS7016: Could Not Find a Declaration File for Module

Could not find a declaration file for module 'X'. 'Y' implicitly has an 'any' type

Strict ModeModulesStrict ModeDeclarations
TS7022

Fix TS7022: Implicitly Has Type 'any'

'x' implicitly has type 'any' because it does not have a type annotation and is referenced directly ...

Strict ModeCircular ReferencesType InferencenoImplicitAny
TS7029

Fix TS7029: Fallthrough Case in Switch

Fallthrough case in switch

Strict ModeCode QualityControl FlowConfig
TS7030

Fix TS7030: Not All Code Paths Return a Value

Not all code paths return a value

Strict ModeStrict ModeFunctionsControl Flow
TS7053

Fix TS7053: Expression Can't Be Used to Index Type

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

Strict ModeStrict ModeIndex SignaturesType Safety
TS8010

Fix TS8010: Type Annotations in JavaScript Files

Type annotations can only be used in TypeScript files

Semantic ErrorJavaScriptType AnnotationsConfig
TS18046

Fix TS18046: 'x' Is of Type 'unknown'

'x' is of type 'unknown'

Semantic ErrorUnknown TypeType GuardsError Handling
TS18047

Fix TS18047: 'x' Is Possibly 'null'

'x' is possibly 'null'

Strict ModeNull SafetyStrict ModeNull Checks
TS18048

Fix TS18048: 'x' Is Possibly 'undefined'

'x' is possibly 'undefined'

Strict ModeNull SafetyStrict ModeType Guards