typescript
TypeScript Compiler Errors
Diagnostic codes emitted by the TypeScript compiler (tsc). Each code is prefixed with TS followed by a number.
82 codes
references typescriptlang.org/tsconfig
· All codes 82 codes
- TS1002 Unterminated String Literal A string literal is missing its closing quote character. This typically occurs when a quote character within the string is not escaped.
- TS1003 Identifier Expected The compiler expected an identifier at this position but found something else. This often indicates a syntax error or a reserved keyword used where a name is required.
- TS1005 Token Expected A specific token (such as `;`, `,`, or `)`) was expected at this position but was not found. This is a general syntax error indicating a structural problem in the code.
- TS1054 Constructor Accessor Not Allowed A `get` or `set` accessor cannot be named `constructor`. Use a regular method instead.
- TS1128 Declaration or Statement Expected The compiler expected a declaration or statement at this position but found something else. This is usually caused by an extra or misplaced closing brace.
- TS1161 Unterminated Regular Expression A regular expression literal is missing its closing `/` delimiter. Check that the regex is properly terminated and that any `/` within the pattern is escaped.
- TS1192 No Default Export The referenced module has no default export. Either import a named export instead, or add a default export to the module.
- TS1238 Abstract Override Not Implemented A class that extends an abstract class must implement all of its abstract members. Add concrete implementations for the missing abstract methods or properties.
- TS1343 Import Assertion Not Permitted Import assertions (the `assert` keyword on import statements) are not permitted in this context or with the current module settings. Check your `module` compiler option.
- TS2304 Cannot Find Name The compiler cannot resolve a name used in the code. The variable, function, or type may not be declared, may be out of scope, or may require a type declaration package (e.g. `@types/node`).
- TS2305 Module Has No Exported Member The named export does not exist in the referenced module. Check the module's exports or verify the import spelling.
- TS2307 Cannot Find Module The compiler cannot locate the imported module. The package may not be installed, the path may be wrong, or type declarations may be missing.
- TS2314 Generic Type Requires Type Arguments A generic type was referenced without providing the required type arguments. Supply the expected number of type parameters in angle brackets.
- TS2322 Type Not Assignable A value of one type cannot be assigned to a variable or parameter of another type. This is one of the most common TypeScript errors, indicating a type mismatch.
- TS2339 Property Does Not Exist The accessed property does not exist on the given type. The property may be misspelled, the wrong type may be in use, or the type definition may need updating.
- TS2341 Private Property Inaccessible A property marked `private` is being accessed from outside the class in which it is declared. Use a public accessor method or change the visibility modifier.
- TS2345 Argument Type Not Assignable The type of an argument passed to a function is not compatible with the declared parameter type. Check the function signature and the value being passed.
- TS2349 Not Callable An expression is being called as a function, but its type does not have a call signature. The value may not be a function, or the type may be incorrect.
- TS2351 Not a Constructor A `new` expression is used on a value whose type has no construct signature. The value is not a class or constructor function.
- TS2355 Function Missing Return Statement A function whose return type is not `void` or `any` is missing a `return` statement in one or more code paths. Ensure all code paths return a value.
- TS2362 Left Operand Not Number or Any The left-hand side of an arithmetic operation must be of type `number`, `bigint`, or `any`. Check the types involved in the expression.
- TS2363 Right Operand Not Number or Any The right-hand side of an arithmetic operation must be of type `number`, `bigint`, or `any`. Check the types involved in the expression.
- TS2365 Operator Not Applied to Types An operator cannot be applied to the given operand types. For example, using `+` on two objects that are not strings or numbers.
- TS2366 Function Lacks Return Statement Not all code paths in a function return a value. Add explicit `return` statements to every branch, or adjust the declared return type to include `undefined`.
- TS2375 Duplicate Identifier with Different Type A declaration with this name already exists in scope with an incompatible type. Merge or rename one of the declarations.
- TS2378 Getter Must Return Value A `get` accessor is declared but does not return a value on all code paths. Ensure the getter always returns a value of the expected type.
- TS2380 Getter and Setter Must Agree The return type of a `get` accessor is not assignable to the parameter type of its corresponding `set` accessor. Align the types of the getter and setter.
- TS2395 Individual Declarations Must Be All Ambient When merging declarations of the same name, all declarations must consistently be ambient (i.e. use `declare`) or all must be non-ambient. You cannot mix the two.
- TS2403 Subsequent Variable Declarations Must Have Same Type A variable declared more than once (via declaration merging) has a different type in subsequent declarations. Ensure all declarations of the same variable agree on their type.
- TS2416 Property Not Compatible with Base Type A property in a derived class is not assignable to the same property in the base class or interface it implements. The overriding property must be a subtype of the base property.
- TS2420 Class Incorrectly Implements Interface A class declares that it `implements` an interface but is missing one or more required members. Add the missing properties or methods to satisfy the interface contract.
- TS2430 Interface Cannot Extend Class An interface is attempting to extend a class in a way that is not compatible with the interface's declared members. Review the inheritance relationship between the class and interface.
- TS2440 Import Cannot Be Named A namespace import (`import * as foo`) cannot be used with `export =` style modules. Use a default import or a CommonJS-style `require` instead.
- TS2448 Variable Used Before Assignment A variable is referenced before it is assigned a value in the current code path. Initialise the variable before use, or use definite assignment assertion (`!`) if you are certain it is set.
- TS2451 Cannot Redeclare Block-Scoped Variable A `let` or `const` variable is declared more than once in the same scope. Each block-scoped variable name must be unique within its scope.
- TS2454 Variable Used Before Being Assigned TypeScript's control-flow analysis has determined that a variable may not be assigned when it is read. Ensure the variable is initialised on all code paths before it is used.
- TS2456 Type Alias Circularly References Itself A type alias directly or indirectly references itself in a way that is not permitted. Use an interface instead, or restructure the type to break the cycle.
- TS2461 Type Not an Array Type Destructuring with array syntax was used on a value that is not typed as an array or iterable. Verify the type of the value being destructured.
- TS2488 Type Not Iterable A `for...of` loop is used on a value whose type does not have an iterator. Ensure the value is an array, string, or other iterable type, or enable `downlevelIteration`.
- TS2531 Object Is Possibly Null An operation is being performed on a value that may be `null`. Use a null check, optional chaining (`?.`), or a non-null assertion (`!`) if you are certain the value is not null.
- TS2532 Object Is Possibly Undefined An operation is being performed on a value that may be `undefined`. Use an `undefined` check, optional chaining (`?.`), or a non-null assertion (`!`) to handle this case.
- TS2533 Object Is Possibly Null or Undefined An operation is being performed on a value that may be either `null` or `undefined`. Guard against both values before accessing properties or calling methods on the value.
- TS2540 Cannot Assign to Read-Only Property An assignment targets a property that is marked `readonly`. Remove the `readonly` modifier or use a different approach such as object spreading to create a modified copy.
- TS2542 Index Signature Read-Only An index signature is marked `readonly` and cannot be assigned to. Create a writable copy of the object or remove the `readonly` modifier from the index signature.
- TS2551 Property Does Not Exist, Did You Mean The accessed property does not exist on the type, but a similarly named property does. This variant includes a suggestion for the correct spelling.
- TS2554 Wrong Number of Arguments A function call provides a different number of arguments than the function's signature expects. Check the function definition and supply the correct number of arguments.
- TS2556 Spread Argument Not Assignable A spread argument (`...args`) does not match the rest parameter or the remaining parameters of the function. Ensure the spread value's type is compatible with the function signature.
- TS2559 Type Has No Properties in Common An object literal is being assigned to a type, but none of the properties on the literal exist in the target type. This often signals a mismatched type or a typo in a property name.
- TS2564 Property Not Definitely Assigned A class property is declared without a definite assignment and is not initialised in the constructor. Add an initialiser, mark it optional (`?`), or use the definite assignment assertion (`!`).
- TS2571 Object Is of Type Unknown An operation is being performed on a value typed as `unknown`. You must narrow the type with a type guard or type assertion before using it.
- TS2578 Unused @ts-expect-error A `// @ts-expect-error` directive is present but the following line does not produce a TypeScript error. Remove the directive or move it to a line that actually has an error.
- TS2580 Cannot Find Global Name A globally available name (such as `process`, `Buffer`, or `__dirname`) is not recognised. Install the relevant type declarations (e.g. `@types/node`) and reference them in your `tsconfig.json`.
- TS2590 Expression Produces Union Too Complex A union or intersection type has grown too large for the compiler to evaluate. Simplify the type by breaking it into smaller named types or reducing the number of union members.
- TS2602 JSX Factory Not Found The JSX factory (e.g. `React`) is referenced by transformed JSX but is not in scope. Import it explicitly or configure `jsxImportSource` in `tsconfig.json`.
- TS2604 JSX Element Missing Attributes A JSX element's attributes do not satisfy the props type expected by the component. Add the missing required props or check the component's type definition.
- TS2606 JSX Element Not Constructor A JSX element references a value that is not a valid JSX constructor (class component or function component). Ensure the referenced value returns JSX or a React element.
- TS2614 Module Has No Exported Member, Did You Mean The imported name does not exist in the module, but a similarly named export does. This variant includes a suggested correction.
- TS2683 this Implicitly Has Type any `this` is used in a context where its type cannot be inferred and implicitly becomes `any`. Add an explicit `this` parameter to the function signature or enable `noImplicitThis`.
- TS2693 Type Used as Value A type or interface name is being used where a value is expected. Types are erased at runtime; use a class, enum, or value instead.
- TS2769 No Overload Matches Call None of the overload signatures for a function match the provided arguments. Review the function's overload signatures and ensure the argument types and count match one of them.
- TS2774 Condition Always True TypeScript's type narrowing has determined that a condition is always `true` and therefore the check is unnecessary. Remove the condition or revise the types involved.
- TS2775 Condition Always False TypeScript's type narrowing has determined that a condition is always `false` and the associated code is unreachable. Review the types involved or remove the dead branch.
- TS4022 Top-Level await Not Permitted Top-level `await` is used but the `module` setting in `tsconfig.json` does not support it. Set `module` to `es2022`, `esnext`, `node16`, or `nodenext` to enable top-level `await`.
- TS4023 Exported Variable Has Unexported Type An exported variable's inferred type references a type that is not exported. Explicitly annotate the variable with an exported type, or export the referenced type.
- TS4055 Return Type Has Unexported Name A public function's return type contains a type name that is not exported from the module. Export the type or provide an explicit, fully-exported return type annotation.
- TS4114 Override Modifier Required A method overrides a base class method but is missing the `override` keyword. Add `override` to the method declaration, or disable `noImplicitOverride` in `tsconfig.json`.
- TS5023 Unknown Compiler Option An unrecognised option was passed to the TypeScript compiler. Check the option name for typos and verify it is supported by the version of TypeScript in use.
- TS5025 Cannot Find tsconfig The TypeScript compiler cannot locate a `tsconfig.json` file at the specified or default path. Ensure the file exists in the project root or pass the correct path with `--project`.
- TS5055 Cannot Overwrite Input File The compiler output file would overwrite one of the input source files. Adjust the `outDir` or `outFile` options in `tsconfig.json` to direct output to a different location.
- TS5082 Cannot Use Bundler Module Resolution Without moduleResolution The `bundler` module resolution mode requires `module` to be set to `es2015` or later. Update the `module` and `moduleResolution` settings in `tsconfig.json` to be compatible.
- TS6133 Declared But Never Read A variable, parameter, or import is declared but never used. Remove the declaration or prefix the name with `_` to signal intentional non-use. Controlled by the `noUnusedLocals` and `noUnusedParameters` options.
- TS6142 Module Resolved to Non-TypeScript File A module resolved to a file (such as a `.json` or `.css` file) that TypeScript cannot type-check directly. Add a declaration file or configure the appropriate module resolver plugin.
- TS6196 Declared But Its Value Never Read A variable is declared and assigned but its value is never subsequently read. This indicates dead code; either remove the variable or use the value.
- TS7006 Parameter Implicitly Has any Type A function parameter has no type annotation and its type cannot be inferred, so it implicitly becomes `any`. Add a type annotation or enable `noImplicitAny` to enforce explicit typing.
- TS7015 Element Implicitly Has any Type (index) An object is indexed with an expression whose result type is `any`, leading to an implicit `any` for the element. Use a typed key or add an index signature to the object's type.
- TS7016 Could Not Find Declaration File for Module TypeScript cannot find type declarations for the imported JavaScript module. Install the corresponding `@types/` package or add a local `declare module` statement.
- TS7017 Element Implicitly Has any Type (no index signature) An object is indexed with a string or number key, but the object's type has no index signature, causing an implicit `any`. Add an index signature or use `Record<K, V>` to type the object properly.
- TS7019 Rest Parameter Implicitly Has any Type A rest parameter (`...args`) has no type annotation and defaults to an implicit `any[]`. Add an explicit array type annotation to the rest parameter.
- TS7022 Variable Implicitly Has any Type A variable's type cannot be inferred from its initialiser and defaults to implicit `any`. Provide an explicit type annotation or initialise the variable with a value from which the type can be inferred.
- TS7031 Binding Element Implicitly Has any Type A destructured binding element has no type that can be inferred, resulting in an implicit `any`. Add a type annotation to the destructuring pattern or the enclosing function parameter.
- TS7034 Variable Implicitly Has any in Some Locations A variable widens to `any` because it is assigned values of different types across multiple code paths. Provide an explicit type annotation to constrain the variable's type.
- TS7053 Element Implicitly Has any Type (expression) An expression is used to index an object, but the object's type does not have an index signature matching that key type, resulting in an implicit `any`. Add an index signature or use a typed access pattern.