Error TS2550 “Property ‘includes’ does not exist on type ‘string'” means your lib setting is older than ES2015, so TypeScript doesn’t know String.prototype.includes exists. Fix it in tsconfig.json by setting lib (or target) to es2015 or later, such as:
"compilerOptions": { "target": "es2024", "lib": ["es2024", "dom"] }
These errors come straight from TypeScript 7.0.2 and Node.js v22.22.2. A few of the messages changed in TypeScript 7, so the exact wording below may differ from older posts.
You’ll see the error for strings and for arrays, why an explicit lib overrides your target, the tsconfig fix, TypeScript 7 rejecting –target es5, and an indexOf fallback.
Reproduce error TS2550 for string includes
The error appears when the compiler only loads the ES5 library, where strings have no includes(). The message even tells you which lib adds it:
declare const console: { log(...args: unknown[]): void }; // stands in for @types/node or the dom lib
const city: string = "San Antonio";
console.log(city.includes("Antonio"));
Output:
search_es5.ts(4,18): error TS2550: Property 'includes' does not exist on type 'string'. Do you need to change your target library? Try changing the 'lib' compiler option to 'es2015' or later.

includes() itself is plain string searching; the alternatives are in checking if a string contains a substring in TypeScript.
Why does includes fail on an array with lib es2015?
Array.prototype.includes arrived one version later, in ES2016. So a project on ES2015 compiles string checks but fails on arrays:
const states: string[] = ["TX", "CA", "NY"];
console.log(states.includes("TX"));
Output:
states.ts(2,20): error TS2550: Property 'includes' does not exist on type 'string[]'. Do you need to change your target library? Try changing the 'lib' compiler option to 'es2016' or later.

The array version is how you’d check membership; more options are in checking if a value exists in an array in TypeScript.
Why does lib override target in tsconfig.json?
If you leave out lib, TypeScript picks one that matches target. Once you list lib yourself, that list is all you get. Old projects often still say ["es5", "dom"]:
{
"compilerOptions": {
"target": "es2015",
"lib": ["es5", "dom"],
"strict": true
},
"files": ["search.ts"]
}
Output:
search.ts(5,20): error TS2550: Property 'includes' does not exist on type 'string[]'. Do you need to change your target library? Try changing the 'lib' compiler option to 'es2016' or later.

In my run, adding dom was enough for the string method, but not for the array one. Don’t rely on that: list the ES version you actually target. Newer Intl date options depend on lib too, as in formatting dates in TypeScript.
Fix TS2550 by updating lib in tsconfig.json
Set lib to the same year as your target, plus dom for browser code. Then both calls compile and run:
{
"compilerOptions": {
"target": "es2024",
"lib": ["es2024", "dom"],
"strict": true
},
"files": ["search.ts"]
}
Output:
true
true

Remove lib entirely if you don’t need anything special; the target’s default is usually right. Settings like this are why I keep a template, as in creating an empty string array in TypeScript.
TypeScript 7 no longer accepts –target es5
Older answers say “set target to es5 and add lib es2015”. In TypeScript 7 that target is gone, and the compiler stops before type checking:
const city: string = "San Antonio";
const states: string[] = ["TX", "CA", "NY"];
console.log(city.includes("Antonio"));
console.log(states.includes("TX"));
Output:
error TS5108: Option 'target=ES5' has been removed. Please remove it from your configuration.
If you must support very old browsers, compile to ES2015 and transpile further with a bundler. Other compiler errors are covered in checking if an object is undefined in TypeScript.
Use indexOf() when you can’t change lib
If the config isn’t yours to change, indexOf() exists in ES5 and gives the same answer, with one exception:
const city: string = "San Antonio";
const states: string[] = ["TX", "CA", "NY"];
console.log(city.indexOf("Antonio") !== -1); // same answer as includes()
console.log(states.indexOf("TX") !== -1);
console.log([NaN].indexOf(NaN) !== -1, [NaN].includes(NaN)); // the one difference
Output:
true
true
false true
indexOf can’t find NaN, while includes can. For strings and normal values, the two are interchangeable, and indexOf is also the first step in removing an item from an array in TypeScript.
TS2550 fixes compared
| Situation | Fix |
|---|---|
lib: ["es5"] in tsconfig | lib: ["es2024", "dom"] or remove lib |
| Array includes with ES2015 | lib es2016 or later |
--target es5 in TypeScript 7 | Target es2015+ and transpile with a bundler |
| Can’t edit tsconfig | indexOf(x) !== -1 |
Here are more TypeScript fixes and guides on strings and arrays:
- Check if a TypeScript array contains a value
- Replace all occurrences of a substring
- Remove a substring from a string in TypeScript
- Check a string’s length in TypeScript
Frequently asked questions
What does error TS2550 mean?
The property exists in a newer JavaScript version than your lib setting includes. The message names the lib you need.
How do I fix ‘includes’ does not exist on type ‘string’?
Set "lib": ["es2015"] or later in tsconfig.json, or remove lib so it follows your target.
Why does array includes need es2016?
Array.prototype.includes was added in ES2016, one year after string includes.
Can I still use –target es5 in TypeScript 7?
No. TypeScript 7 reports TS5108 because the option was removed. Target es2015 or later.
Is indexOf a safe replacement for includes?
Yes, except that indexOf can’t find NaN in arrays.
Where is the lib compiler option documented?

Bijay Kumar is a 13-time Microsoft MVP with more than 18 years in software development, and the founder of Python Guides and TSinfo Technologies. He started out building .NET and SharePoint solutions at HP, TCS and KPIT before moving into Python, machine learning and AI, and he also builds web apps with TypeScript and React. He writes the tutorials here himself, and every example is run before publishing so you see the real output. More about Bijay · Microsoft MVP profile · LinkedIn