Error codes

One page per diagnostic code: the message, what it means, a minimal example and how to fix it. Codes and messages match tsc 7.0.2, so a page here also explains the same error from tsc.

ts-r can report 350 diagnostic codes today (cargo xtask diag-codes lists them from the source). This first pass documents 249 of them, plus 45 sound-mode codes. This pass picks the codes that turn up most: first those ts-r-check reports on private-app (all 25 tsconfig projects, run on 2026-10-15 at commit 6deaf01) and those behind failure causes in the ecosystem run of the top 1,000 npm packages (2026-10-14), then the rest by how often tsc 7.0.2's own test baselines report them. All TS8xxx and TS99xxx codes are included.

Every example was run through ts-r-check and is shown only if ts-r reported the page’s code; 237 pages have one. Pages without an example are codes we couldn’t trigger with a minimal input yet.

TypeScript codes

Codes ts-r reports with tsc 7’s code and message.

  • TS1002 Unterminated string literal.
  • TS1003 Identifier expected.
  • TS1005 '…' expected.
  • TS1011 An element access expression should take an argument.
  • TS1013 A rest parameter or binding pattern may not have a trailing comma.
  • TS1028 Accessibility modifier already seen.
  • TS1029 '…' modifier must precede '…' modifier.
  • TS1030 '…' modifier already seen.
  • TS1042 '…' modifier cannot be used here.
  • TS1044 '…' modifier cannot appear on a module or namespace element.
  • TS1068 Unexpected token. A constructor, method, accessor, or property was expected.
  • TS1070 '…' modifier cannot appear on a type member.
  • TS1090 '…' modifier cannot appear on a parameter.
  • TS1097 '…' list cannot be empty.
  • TS1100 Invalid use of '…' in strict mode.
  • TS1101 'with' statements are not allowed in strict mode.
  • TS1102 'delete' cannot be called on an identifier in strict mode.
  • TS1109 Expression expected.
  • TS1110 Type expected.
  • TS1114 Duplicate label '…'.
  • TS1117 An object literal cannot have multiple properties with the same name.
  • TS1118 An object literal cannot have multiple get/set accessors with the same name.
  • TS1119 An object literal cannot have property and accessor with the same name.
  • TS1121 Octal literals are not allowed. Use the syntax '…'.
  • TS1124 Digit expected.
  • TS1125 Hexadecimal digit expected.
  • TS1127 Invalid character.
  • TS1128 Declaration or statement expected.
  • TS1131 Property or signature expected.
  • TS1134 Variable declaration expected.
  • TS1135 Argument expression expected.
  • TS1136 Property assignment expected.
  • TS1138 Parameter declaration expected.
  • TS1141 String literal expected.
  • TS1146 Declaration expected.
  • TS1160 Unterminated template literal.
  • TS1162 An object member cannot be declared optional.
  • TS1163 A 'yield' expression is only allowed in a generator body.
  • TS1181 Array element destructuring pattern expected.
  • TS1184 Modifiers cannot appear here.
  • TS1192 Module '…' has no default export.
  • TS1196 Catch clause variable type annotation must be 'any' or 'unknown' if specified.
  • TS1199 Unterminated Unicode escape sequence.
  • TS1200 Line terminator not permitted before arrow.
  • TS1206 Decorators are not valid here.
  • TS1210 Code contained in a class is evaluated in JavaScript's strict mode which does not allow this use of '…'. For more information, see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Strict_mode.
  • TS1212 Identifier expected. '…' is a reserved word in strict mode.
  • TS1213 Identifier expected. '…' is a reserved word in strict mode. Class definitions are automatically in strict mode.
  • TS1214 Identifier expected. '…' is a reserved word in strict mode. Modules are automatically in strict mode.
  • TS1215 Invalid use of '…'. Modules are automatically in strict mode.
  • TS1243 '…' modifier cannot be used with '…' modifier.
  • TS1244 Abstract methods can only appear within an abstract class.
  • TS1249 A decorator can only decorate a method implementation, not an overload.
  • TS1253 Abstract properties can only appear within an abstract class.
  • TS1344 A label is not allowed here.
  • TS1345 An expression of type 'void' cannot be tested for truthiness.
  • TS1351 An identifier or keyword cannot immediately follow a numeric literal.
  • TS1359 Identifier expected. '…' is a reserved word that cannot be used here.
  • TS1360 Type '…' does not satisfy the expected type '…'.
  • TS1381 Unexpected token. Did you mean `{'}'}` or `}`?
  • TS1382 Unexpected token. Did you mean `{'>'}` or `>`?
  • TS1433 Neither decorators nor modifiers may be applied to 'this' parameters.
  • TS1477 An instantiation expression cannot be followed by a property access.
  • TS1489 Decimals with leading zeros are not allowed.
  • TS1497 Expression must be enclosed in parentheses to be used as a decorator.
  • TS1499 Unknown regular expression flag.
  • TS1500 Duplicate regular expression flag.
  • TS1502 The Unicode (u) flag and the Unicode Sets (v) flag cannot be set simultaneously.
  • TS2300 Duplicate identifier '…'.
  • TS2304 Cannot find name '…'.
  • TS2305 Module '…' has no exported member '…'.
  • TS2307 Cannot find module '…' or its corresponding type declarations.
  • TS2314 Generic type '…' requires … type argument(s).
  • TS2315 Type '…' is not generic.
  • TS2320 Interface '…' cannot simultaneously extend types '…' and '…'.
  • TS2322 Type '…' is not assignable to type '…'.
  • TS2339 Property '…' does not exist on type '…'.
  • TS2341 Property '…' is private and only accessible within class '…'.
  • TS2344 Type '…' does not satisfy the constraint '…'.
  • TS2345 Argument of type '…' is not assignable to parameter of type '…'.
  • TS2348 Value of type '…' is not callable. Did you mean to include 'new'?
  • TS2349 This expression is not callable.
  • TS2351 This expression is not constructable.
  • TS2352 Conversion of type '…' to type '…' may be a mistake because neither type sufficiently overlaps with the other. If this was intentional, convert the expression to 'unknown' first.
  • TS2353 Object literal may only specify known properties, and '…' does not exist in type '…'.
  • TS2355 A function whose declared type is neither 'undefined', 'void', nor 'any' must return a value.
  • TS2356 An arithmetic operand must be of type 'any', 'number', 'bigint' or an enum type.
  • TS2357 The operand of an increment or decrement operator must be a variable or a property access.
  • TS2358 The left-hand side of an 'instanceof' expression must be of type 'any', an object type or a type parameter.
  • TS2359 The right-hand side of an 'instanceof' expression must be either of type 'any', a class, function, or other type assignable to the 'Function' interface type, or an object type with a 'Symbol.hasInstance' method.
  • TS2362 The left-hand side of an arithmetic operation must be of type 'any', 'number', 'bigint' or an enum type.
  • TS2363 The right-hand side of an arithmetic operation must be of type 'any', 'number', 'bigint' or an enum type.
  • TS2365 Operator '…' cannot be applied to types '…' and '…'.
  • TS2366 Function lacks ending return statement and return type does not include 'undefined'.
  • TS2367 This comparison appears to be unintentional because the types '…' and '…' have no overlap.
  • TS2369 A parameter property is only allowed in a constructor implementation.
  • TS2383 Overload signatures must all be exported or non-exported.
  • TS2384 Overload signatures must all be ambient or non-ambient.
  • TS2385 Overload signatures must all be public, private or protected.
  • TS2386 Overload signatures must all be optional or required.
  • TS2387 Function overload must be static.
  • TS2388 Function overload must not be static.
  • TS2389 Function implementation name must be '…'.
  • TS2390 Constructor implementation is missing.
  • TS2391 Function implementation is missing or not immediately following the declaration.
  • TS2392 Multiple constructor implementations are not allowed.
  • TS2393 Duplicate function implementation.
  • TS2394 This overload signature is not compatible with its implementation signature.
  • TS2403 Subsequent variable declarations must have the same type. Variable '…' must be of type '…', but here has type '…'.
  • TS2407 The right-hand side of a 'for...in' statement must be of type 'any', an object type or a type parameter, but here has type '…'.
  • TS2411 Property '…' of type '…' is not assignable to '…' index type '…'.
  • TS2413 '…' index type '…' is not assignable to '…' index type '…'.
  • TS2415 Class '…' incorrectly extends base class '…'.
  • TS2416 Property '…' in type '…' is not assignable to the same property in base type '…'.
  • TS2417 Class static side '…' incorrectly extends base class static side '…'.
  • TS2420 Class '…' incorrectly implements interface '…'.
  • TS2430 Interface '…' incorrectly extends interface '…'.
  • TS2435 Ambient modules cannot be nested in other modules or namespaces.
  • TS2445 Property '…' is protected and only accessible within class '…' and its subclasses.
  • TS2447 The '…' operator is not allowed for boolean types. Consider using '…' instead.
  • TS2448 Block-scoped variable '…' used before its declaration.
  • TS2449 Class '…' used before its declaration.
  • TS2450 Enum '…' used before its declaration.
  • TS2451 Cannot redeclare block-scoped variable '…'.
  • TS2454 Variable '…' is used before being assigned.
  • TS2464 A computed property name must be of type 'string', 'number', 'symbol', or 'any'.
  • TS2469 The '…' operator cannot be applied to type 'symbol'.
  • TS2488 Type '…' must have a '[Symbol.iterator]()' method that returns an iterator.
  • TS2493 Tuple type '…' of length '…' has no element at index '…'.
  • TS2503 Cannot find namespace '…'.
  • TS2511 Cannot create an instance of an abstract class.
  • TS2512 Overload signatures must all be abstract or non-abstract.
  • TS2515 Non-abstract class '…' does not implement inherited abstract member … from class '…'.
  • TS2528 A module cannot have multiple default exports.
  • TS2531 Object is possibly 'null'.
  • TS2532 Object is possibly 'undefined'.
  • TS2534 A function returning 'never' cannot have a reachable end point.
  • TS2538 Type '…' cannot be used as an index type.
  • TS2540 Cannot assign to '…' because it is a read-only property.
  • TS2542 Index signature in type '…' only permits reading.
  • TS2551 Property '…' does not exist on type '…'. Did you mean '…'?
  • TS2552 Cannot find name '…'. Did you mean '…'?
  • TS2554 Expected … arguments, but got ….
  • TS2555 Expected at least … arguments, but got ….
  • TS2556 A spread argument must either have a tuple type or be passed to a rest parameter.
  • TS2558 Expected … type arguments, but got ….
  • TS2559 Type '…' has no properties in common with type '…'.
  • TS2561 Object literal may only specify known properties, but '…' does not exist in type '…'. Did you mean to write '…'?
  • TS2564 Property '…' has no initializer and is not definitely assigned in the constructor.
  • TS2567 Enum declarations can only merge with namespace or other enum declarations.
  • TS2575 No overload expects … arguments, but overloads do exist that expect either … or … arguments.
  • TS2576 Property '…' does not exist on type '…'. Did you mean to access the static member '…' instead?
  • TS2578 Unused '@ts-expect-error' directive.
  • TS2584 Cannot find name '…'. Do you need to change your target library? Try changing the 'lib' compiler option to include 'dom'.
  • TS2588 Cannot assign to '…' because it is a constant.
  • TS2589 Type instantiation is excessively deep and possibly infinite.
  • TS2591 Cannot find name '…'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node` and then add 'node' to the types field in your tsconfig.
  • TS2592 Cannot find name '…'. Do you need to install type definitions for jQuery? Try `npm i --save-dev @types/jquery` and then add 'jquery' to the types field in your tsconfig.
  • TS2593 Cannot find name '…'. Do you need to install type definitions for a test runner? Try `npm i --save-dev @types/jest` or `npm i --save-dev @types/mocha` and then add 'jest' or 'mocha' to the types field in your tsconfig.
  • TS2610 '…' is defined as an accessor in class '…', but is overridden here in '…' as an instance property.
  • TS2611 '…' is defined as a property in class '…', but is overridden here in '…' as an accessor.
  • TS2628 Cannot assign to '…' because it is an enum.
  • TS2629 Cannot assign to '…' because it is a class.
  • TS2630 Cannot assign to '…' because it is a function.
  • TS2631 Cannot assign to '…' because it is a namespace.
  • TS2654 Non-abstract class '…' is missing implementations for the following members of '…': ….
  • TS2664 Invalid module name in augmentation, module '…' cannot be found.
  • TS2669 Augmentations for the global scope can only be directly nested in external modules or ambient module declarations.
  • TS2678 Type '…' is not comparable to type '…'.
  • TS2683 'this' implicitly has type 'any' because it does not have a type annotation.
  • TS2688 Cannot find type definition file for '…'.
  • TS2693 '…' only refers to a type, but is being used as a value here.
  • TS2694 Namespace '…' has no exported member '…'.
  • TS2703 The operand of a 'delete' operator must be a property reference.
  • TS2707 Generic type '…' requires between … and … type arguments.
  • TS2708 Cannot use namespace '…' as a value.
  • TS2717 Subsequent property declarations must have the same type. Property '…' must be of type '…', but here has type '…'.
  • TS2720 Class '…' incorrectly implements class '…'. Did you mean to extend '…' and inherit its members as a subclass?
  • TS2722 Cannot invoke an object which is possibly 'undefined'.
  • TS2729 Property '…' is used before its initialization.
  • TS2739 Type '…' is missing the following properties from type '…': …
  • TS2740 Type '…' is missing the following properties from type '…': …, and … more.
  • TS2741 Property '…' is missing in type '…' but required in type '…'.
  • TS2749 '…' refers to a value, but is being used as a type here. Did you mean 'typeof …'?
  • TS2769 No overload matches this call.
  • TS2790 The operand of a 'delete' operator must be optional.
  • TS2882 Cannot find module or type declarations for side-effect import of '…'.
  • TS4104 The type '…' is 'readonly' and cannot be assigned to the mutable type '…'.
  • TS4112 This member cannot have an 'override' modifier because its containing class '…' does not extend another class.
  • TS4113 This member cannot have an 'override' modifier because it is not declared in the base class '…'.
  • TS4114 This member must have an 'override' modifier because it overrides a member in the base class '…'.
  • TS4115 This parameter property must have an 'override' modifier because it overrides a member in base class '…'.
  • TS4127 This member cannot have an 'override' modifier because its name is dynamic.
  • TS5052 Option '…' cannot be specified without specifying option '…'.
  • TS5053 Option '…' cannot be specified with option '…'.
  • TS5055 Cannot write file '…' because it would overwrite input file.
  • TS5061 Pattern '…' can have at most one '*' character.
  • TS5062 Substitution '…' in pattern '…' can have at most one '*' character.
  • TS5069 Option '…' cannot be specified without specifying option '…' or option '…'.
  • TS5076 '…' and '…' operations cannot be mixed without parentheses.
  • TS5090 Non-relative paths are not allowed. Did you forget a leading './'?
  • TS5095 Option '…' can only be used when 'module' is set to 'preserve', 'commonjs', or 'es2015' or later.
  • TS5102 Option '…' has been removed. Please remove it from your configuration.
  • TS5110 Option 'module' must be set to '…' when option 'moduleResolution' is set to '…'.
  • TS6053 File '…' not found.
  • TS6133 '…' is declared but its value is never read.
  • TS6142 Module '…' was resolved to '…', but '--jsx' is not set.
  • TS6188 Numeric separators are not allowed here.
  • TS6189 Multiple consecutive numeric separators are not permitted.
  • TS6196 '…' is declared but never used.
  • TS7006 Parameter '…' implicitly has an '…' type.
  • TS7009 'new' expression, whose target lacks a construct signature, implicitly has an 'any' type.
  • TS7010 '…', which lacks return-type annotation, implicitly has an '…' return type.
  • TS7013 Construct signature, which lacks return-type annotation, implicitly has an 'any' return type.
  • TS7015 Element implicitly has an 'any' type because index expression is not of type 'number'.
  • TS7016 Could not find a declaration file for module '…'. '…' implicitly has an 'any' type.
  • TS7026 JSX element implicitly has type 'any' because no interface 'JSX.…' exists.
  • TS7027 Unreachable code detected.
  • TS7028 Unused label.
  • TS7032 Property '…' implicitly has type 'any', because its set accessor lacks a parameter type annotation.
  • TS7053 Element implicitly has an 'any' type because expression of type '…' can't be used to index type '…'.
  • TS17002 Expected corresponding JSX closing tag for '…'.
  • TS17004 Cannot use JSX unless the '--jsx' flag is provided.
  • TS17006 An unary expression with the '…' operator is not allowed in the left-hand side of an exponentiation expression. Consider enclosing the expression in parentheses.
  • TS17007 A type assertion expression is not allowed in the left-hand side of an exponentiation expression. Consider enclosing the expression in parentheses.
  • TS17008 JSX element '…' has no corresponding closing tag.
  • TS18013 Property '…' is not accessible outside class '…' because it has a private identifier.
  • TS18046 '…' is of type 'unknown'.
  • TS18047 '…' is possibly 'null'.
  • TS18048 '…' is possibly 'undefined'.
  • TS18049 '…' is possibly 'null' or 'undefined'.
  • TS18050 The value '…' cannot be used here.

TypeScript syntax in JavaScript files (TS8xxx)

ts-r’s parser reports these like tsc when it reads .js files with tsc’s rules for TypeScript syntax. ts-r-check does not report them yet.

  • TS8002 'import ... =' can only be used in TypeScript files.
  • TS8003 'export =' can only be used in TypeScript files.
  • TS8004 Type parameter declarations can only be used in TypeScript files.
  • TS8005 'implements' clauses can only be used in TypeScript files.
  • TS8006 '…' declarations can only be used in TypeScript files.
  • TS8008 Type aliases can only be used in TypeScript files.
  • TS8009 The '…' modifier can only be used in TypeScript files.
  • TS8010 Type annotations can only be used in TypeScript files.
  • TS8011 Type arguments can only be used in TypeScript files.
  • TS8012 Parameter modifiers can only be used in TypeScript files.
  • TS8013 Non-null assertions can only be used in TypeScript files.
  • TS8016 Type assertion expressions can only be used in TypeScript files.
  • TS8017 Signature declarations can only be used in TypeScript files.
  • TS8037 Type satisfaction expressions can only be used in TypeScript files.

ts-r’s own codes (TS99xxx)

Limits that keep ts-r from crashing on pathological input. tsc has no equivalent.

  • TS99001 Maximum nesting depth exceeded; the rest of this construct was skipped.
  • TS99002 File is too large to parse (over 4 GiB).
  • TS99003 The parser stopped making progress; the rest of this file was skipped.

Sound-mode codes (TSR)

Diagnostics from sound mode (design record 0007, Accepted), reported only in files that opt in. Their examples are the record’s spec cases, not runs.

  • TSR0001 '@ts-r-unsafe' needs a reason: write '// @ts-r-unsafe: <why this is safe>'.
  • TSR0002 Unused '@ts-r-unsafe' directive: the next line has no sound-mode error.
  • TSR0003 Unknown sound-mode rule '…' in '@ts-r-unsafe'. Rules are S-01 to S-14.
  • TSR0004 Unknown level '…' in '@ts-r' pragma. Use 'off', 'strict', 'sound' or 'contracts'.
  • TSR0005 The '@ts-r' pragma must come before the first statement; this one is ignored.
  • TSR0010 … (sound mode enables 'isolatedDeclarations').
  • TSR0011 … (sound mode enables '…').
  • TSR0020 Invalid sound-mode configuration: ….
  • TSR0101 Type 'any' is not allowed in sound mode. Use 'unknown', a type parameter or a specific type.
  • TSR0102 '…' is 'unknown' in sound mode because '…' declares it as 'any'. Narrow it or parse it with 'parse<T>'.
  • TSR0103 Calling a value of type 'Function' returns 'any'. Give '…' a function type.
  • TSR0201 Type assertion from '…' to '…' narrows the type. Use 'parse<…>', 'is<…>' or a narrowing check instead.
  • TSR0301 Non-null assertion is not allowed in sound mode. Narrow '…' with a check, or use 'expect(…, "why")'.
  • TSR0401 … (sound mode enables 'noUncheckedIndexedAccess': indexed reads can be 'undefined').
  • TSR0402 … (sound mode enables 'exactOptionalPropertyTypes': write '…?: T | undefined' to allow 'undefined').
  • TSR0501 '…' is not assignable to '…': mutable '…' is invariant in sound mode, so writes through '…' could break '…'. Use '…' if it is only read.
  • TSR0601 Method '…' is not compatible: parameter '…' of type '…' would receive '…'. Methods are checked like functions in sound mode.
  • TSR0701 Type predicate '… is …' is not proved: when it returns true, '…' can be '…'.
  • TSR0702 Type predicate '… is …' is not proved: when it returns false, '…' can still be '…'.
  • TSR0703 Assertion '…' is not proved: the function can return normally with '…' of type '…'.
  • TSR0801 Definite assignment assertion on '…' is not allowed in sound mode. Initialise it in its declaration or the constructor.
  • TSR0802 'this' escapes before '…' is initialised. Assign every field first.
  • TSR0803 'this' escapes from the constructor through '…' before subclass fields are initialised. Make it '#private', or do this after construction (a static factory).
  • TSR0901 '…' may have changed since it was narrowed: '…' on line … can modify it. Copy it to a 'const' before that point.
  • TSR0902 '…' may have changed since it was narrowed: it is assigned in a closure, and '…' on line … can run that closure.
  • TSR1001 Promise from '…' is not handled. Await it, return it, or attach '.catch'.
  • TSR1002 'void' discards a promise that can reject. Attach '.catch' first: 'void ….catch(...)'.
  • TSR1003 Async function passed where '…' expects a function returning 'void'; its promise is never handled.
  • TSR1101 Augmenting module '…' in a sound file changes its trusted types without a check. Move the augmentation to a '.d.ts' file.
  • TSR1102 Shorthand ambient module '…' makes every import 'any'. Declare its types in a '.d.ts' file.
  • TSR1103 Ambient declaration '…' in a sound file asserts a value exists without checking it. Move it to a '.d.ts' file or import the real value.
  • TSR1201 '@…' is not allowed in sound mode. Fix the error, or use '// @ts-r-unsafe: <reason>' for sound-mode errors.
  • TSR1202 '@ts-nocheck' cannot be used in a sound file. Set the file to '// @ts-r off' instead.
  • TSR1204 Global augmentation in a sound file changes types for the whole program without a check. Move it to a '.d.ts' file.
  • TSR1205 Overload '…' is not satisfied by its implementation: called through it, the body can return '…', which is not assignable to '…'.
  • TSR1301 '…' can throw '…', which is not in its '@throws' tags. Catch it or add a '@throws' tag for it.
  • TSR1302 Exported '…' can throw '…' but has no '@throws' tag. Document it with a '@throws' tag.
  • TSR1303 Only Error objects can be thrown in sound mode; '…' is not assignable to 'Error'.
  • TSR1304 '…' can throw '…', which '…' (the member it overrides or implements) does not declare.
  • TSR1401 Value from external source '…' must be parsed before use: write 'parse<T>(…)' with the type you expect.
  • TSR1402 '…' needs an explicit type argument in sound mode, e.g. '…<User>(...)'.
  • TSR1501 Type '…' cannot be checked at runtime: ….
  • TSR1502 '…<…>' needs a concrete type, but '…' is a type parameter. Take a 'Guard<…>' argument and call 'guard<User>()' at the call site.
  • TSR1503 '…' from '@ts-r.dev/guard' must be called with a type argument; it can't be used as a value.
  • TSR1504 The validator for '…' is … KB, over the … KB budget. Validate a smaller type or raise '[sound.guard] max-validator-kb'.