TypeScript error

TS2550: A method newer than the configured library

  • Error TS2550
  • Tested with TypeScript 5.9

error TS2550: Property 'at' does not exist on type 'string[]'. Do you need to change your target library? Try changing the 'lib' compiler option to 'es2022' or later. is reported when code calls a built-in method that the checker knows was added in a later ECMAScript year than the libraries it loaded. The message names the year that added it.

It is a version question, not a typo. The checker only knows what your config tells it about the runtime: if target (or lib) says ES2020, methods from 2021 and 2022 are reported, whether or not your Node.js or browsers have them.

At a glance

CodeTS2550
MessageProperty '{0}' does not exist on type '{1}'. Do you need to change your target library? Try changing the 'lib' compiler option to '{2}' or later.
TypeScript's categoryerror
Listed underUnknown names and members
Depends on target, lib
In .js files Reported when the file is checked: checkJs in jsconfig.json, or // @ts-check at the top of the file

The message is TypeScript's own text from its diagnostic messages file (Apache-2.0); {0}, {1} and {2} are filled in by tsc for each error.

What it looks like

tags.js Error confirmed 5.9.3 TypeScript 5.9.3, run 21 October 2026: tags.js(4,15): error TS2550: Property 'at' does not exist on type 'string[]'. Do you need to change your target library? Try changing the 'lib' compiler option to 'es2022' or later. tags.js(10,15): error TS2550: Property 'replaceAll' does not exist on type 'string'. Do you need to change your target library? Try changing the 'lib' compiler option to 'es2021' or later. 6.0.3 TypeScript 6.0.3, run 21 October 2026: the same as 5.9.3. tags.js(4,15): error TS2550: Property 'at' does not exist on type 'string[]'. Do you need to change your target library? Try changing the 'lib' compiler option to 'es2022' or later. tags.js(10,15): error TS2550: Property 'replaceAll' does not exist on type 'string'. Do you need to change your target library? Try changing the 'lib' compiler option to 'es2021' or later. 7.0.2 TypeScript 7.0.2, run 21 October 2026: the same as 5.9.3. tags.js(4,15): error TS2550: Property 'at' does not exist on type 'string[]'. Do you need to change your target library? Try changing the 'lib' compiler option to 'es2022' or later. tags.js(10,15): error TS2550: Property 'replaceAll' does not exist on type 'string'. Do you need to change your target library? Try changing the 'lib' compiler option to 'es2021' or later. checked 21 October 2026
/** @param {string[]} tags */
export function lastTag(tags) {
  return tags.at(-1);error TS2550: Property 'at' does not exist on type 'string[]'. Do you need to change your target library? Try changing the 'lib' compiler option to 'es2022' or later.
}

/** @param {string} slug */
export function titleFromSlug(slug) {
  return slug.replaceAll("-", " ");error TS2550: Property 'replaceAll' does not exist on type 'string'. Do you need to change your target library? Try changing the 'lib' compiler option to 'es2021' or later.
}
Methods newer than the target the config names.
jsconfig.json for this example
{
  "compilerOptions": {
    "checkJs": true,
    "noEmit": true,
    "strict": true,
    "target": "es2020",
    "module": "nodenext",
    "types": []
  },
  "include": ["*.js"]
}

What causes it

  • target or lib names an older year than the method (.at() is ES2022, replaceAll ES2021, Object.entries ES2017, includes ES2016).
  • No target at all, which means es5 in TypeScript 5.9; then Map and Promise fail too, see TS2583.

How to fix it

Raise target when every runtime has the method

Set target to the year the message names or later. Before you do, check that every runtime you support has the method; MDN's compatibility tables list browser and Node.js versions.

tags.js TypeScript 5.9.3 TypeScript 5.9.3, run 21 October 2026: No errors. 6.0.3 TypeScript 6.0.3, run 21 October 2026: the same as 5.9.3. No errors. 7.0.2 TypeScript 7.0.2, run 21 October 2026: the same as 5.9.3. No errors. checked 21 October 2026
/** @param {string[]} tags */
export function lastTag(tags) {
  return tags.at(-1);
}

/** @param {string} slug */
export function titleFromSlug(slug) {
  return slug.replaceAll("-", " ");
}
A target that includes them.
jsconfig.json for this example
{
  "compilerOptions": {
    "checkJs": true,
    "noEmit": true,
    "strict": true,
    "target": "es2022",
    "module": "nodenext",
    "types": []
  },
  "include": ["*.js"]
}

Or write it the older way

If you support runtimes without the method, keep the target and use the older equivalent: tags[tags.length - 1] for .at(-1), split("-").join(" ") or a global regular expression for replaceAll. A polyfill works too, but the checker still needs the newer lib to know the method exists.

Gotchas

  • lib set explicitly overrides the libraries target would pick, so raising target alone does nothing if lib names an old year.
  • The checker never adds polyfills or rewrites the code; noEmit projects run the JavaScript exactly as written.

Sources

Last reviewed 20 October 2026.