-
Notifications
You must be signed in to change notification settings - Fork 12.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
error TS2339: Property 'startsWith' does not exist on type 'string' #12383
Comments
The method endsWith is declared into es6 (es2015). Make sure your target is es6 or higher (if target is not defined defaults to es3) or use lib option to include "es2015.core". |
Thanks, closing! |
We have this but still get the same error {
"compilerOptions": {
"target": "es2015",
"module": "commonjs",
"sourceMap": true
},
"include": [
],
"exclude": [],
"lib":[
"es2015"
]
}
the code:
|
|
thx |
I just ran into this problem in one of my Firebase cloud functions. I can't see anything wrong with my config, you? {
"compilerOptions": {
"target": "es2015",
"module": "commonjs",
"lib": ["es2015", "es2016", "esnext"],
"sourceMap": true,
"outDir": "build",
"strict": true,
"noImplicitAny": true,
"strictNullChecks": true,
"strictFunctionTypes": true,
"noImplicitThis": true,
"alwaysStrict": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"noImplicitReturns": true,
"noFallthroughCasesInSwitch": true,
"moduleResolution": "node",
"plugins": [
{
"name": "tslint-language-service"
}
]
},
"include": ["src/**/*"]
} |
tsc 2.0.10
Code
let tok = ":name";
if(tok.startsWith(":")) <--- false error: error TS2339: Property 'startsWith' does not exist on type 'string'
// A *self-contained* demonstration of the problem follows...
Expected behavior:
should know this is a method on a JS string.
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/startsWith
Actual behavior:
The text was updated successfully, but these errors were encountered: