In this tutorial, I will explain how to fix the error TypeScriptExamples.ts:4:14 – 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.
Error TS2550: Property ‘includes’ Does Not Exist on Type ‘String’ in TypeScript
When working with TypeScript, you might encounter the following error:
TypeScriptExamples.ts:4:14 - 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.This error occurs when TypeScript does not recognize the includes() method on a string variable. The includes() method was introduced in ES6 (ES2015), and if your TypeScript compiler is set to an older ECMAScript version, it won’t recognize the method.
Example Code That Causes the Error
I got this error while checking if a string contains a substring in TypeScript.
let cityName: string = "New York City";
let substring: string = "York";
if (cityName.includes(substring)) {
console.log(`${substring} is found in ${cityName}`);
} else {
console.log(`${substring} is not found in ${cityName}`);
}When you compile this code using an older TypeScript configuration, you might see the TS2550 error because includes() is not recognized.
You can follow the screenshot below for the complete error message:

Why Does This Error Occur?
This error is caused when TypeScript is compiled with a target ECMAScript version lower than ES2015. The includes() method was introduced in ES6 (ES2015), so if your compiler target is set to ES5 or earlier, TypeScript does not recognize includes() as a valid method on strings.
Solutions to Fix the Error
Here are the possible solutions to resolve this error:
1. Update Your TypeScript Configuration (tsconfig.json file)
To support the includes() method, you need to update the lib setting in your tsconfig.json file to include ES2015 or later. Do the following:
- Open your tsconfig.json file (or create one if it doesn’t exist).
- Locate the
compilerOptionssection. - Ensure that the
libsetting includes ES2015 or later.
Updated tsconfig.json File:
{
"compilerOptions": {
"target": "es2016",
"lib": ["ESNext", "DOM"],
"module": "commonjs",
"strict": true,
"esModuleInterop": true,
"forceConsistentCasingInFileNames": true,
"skipLibCheck": true
}
}2. Restart the TypeScript Compiler
If you updated tsconfig.json but the error persists, restart the TypeScript compiler:
tsc --buildOr, if using VS Code, restart the TypeScript server:
- Press
Ctrl + Shift + P - Search for “TypeScript: Restart TS Server”
- Click it to restart the TypeScript server
3. Upgrade Your TypeScript Version
Ensure you’re using an up-to-date version of TypeScript. Run the following command to check your TypeScript version:
tsc -vIf it’s outdated, upgrade it using:
npm install -g typescript4. Use indexOf() Instead of includes() (Alternative Fix for Older Versions)
If you’re working in an environment where you cannot update TypeScript or change tsconfig.json, you can use indexOf() instead of includes():
if (cityName.indexOf(substring) !== -1) {
console.log(`${substring} is found in ${cityName}`);
} else {
console.log(`${substring} is not found in ${cityName}`);
}This works in older JavaScript environments because indexOf() has been supported for a long time.
Conclusion
The TS2550 error occurs when TypeScript does not recognize includes() on a string, usually due to an outdated tsconfig.json configuration. To fix it:
- Ensure
libis set toES2015or later intsconfig.json. - Restart the TypeScript compiler or server.
- Upgrade TypeScript to the latest version.
- Use
indexOf()as an alternative if you cannot update TypeScript.
By following these steps, you can resolve the error and use includes() without any issues.
You may also like:

I am Bijay Kumar, a Microsoft MVP in SharePoint. Apart from SharePoint, I started working on Python, Machine learning, and artificial intelligence for the last 5 years. During this time I got expertise in various Python libraries also like Tkinter, Pandas, NumPy, Turtle, Django, Matplotlib, Tensorflow, Scipy, Scikit-Learn, etc… for various clients in the United States, Canada, the United Kingdom, Australia, New Zealand, etc. Check out my profile.