-
-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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
Property 'includes' does not exist on type 'string[]'. #931
Comments
I can confirm this problem. Obviously this affects to all Arrays, eg. "Property 'includes' does not exist on type 'number[]'." I tried to change the ES target to ES6 with no success. |
Okay, to overcome the issue, I needed to set tsconfig.json compilerOptions.lib from "es6" to "es7" as follows:
I'm not sure if this causes other problems, though. "includes" is implemented for 'string' (not Array) in ES6, and for arrays only in ES7. |
any updates on this? btw I did a different approach to do what let targetClasses: Array<string> = ["open_time", "close_time"];
let isThere: boolean = targetClasses.some(cls => (<HTMLElement>event.target).classList.contains(cls));
... |
I don't think any updates are needed for this, since if you want to use ES7 features on your code, you have to set the "lib" version in tsconfig.json (and tsconfig.webpack.json) to "es7". So I can't see any issues on Angular2 webpack starter or Angular2 itself regarding this. Just set the library version you want, and you are good to go. This issue should be closed, or maybe the default library setting should be changed to ES7. |
What worked for me was just declare array with also its datatype like as: let array = []; instead of just let array; where is its datatype undefined. |
With target set to es6, was receiving error: ERROR in /home/jthetzel/src/react-mapbox-gl/src/layer.ts (206,22): error TS2339: Property 'includes' does not exist on type 'number[]'. Suggestion to try es7: PatrickJS/PatrickJS-starter#931 (comment)
With target set to es6, was receiving error: ERROR in /home/jthetzel/src/react-mapbox-gl/src/layer.ts (206,22): error TS2339: Property 'includes' does not exist on type 'number[]'. Suggestion to try es7: PatrickJS/PatrickJS-starter#931 (comment)
Remove rootDir from example/tsconfig.json Inclusion was causing TS6059 'rootDir' is expected to contain all source files error. Suggestion to remove from: wmonk/create-react-app-typescript#74 Change tsconfig.json compiler target to es7 With target set to es6, was receiving error: ERROR in /home/jthetzel/src/react-mapbox-gl/src/layer.ts (206,22): error TS2339: Property 'includes' does not exist on type 'number[]'. Suggestion to try es7: PatrickJS/PatrickJS-starter#931 (comment) Removing carets from devDependencies Presume this is preferred, as master branch does not use carets.
Remove rootDir from example/tsconfig.json Inclusion was causing TS6059 'rootDir' is expected to contain all source files error. Suggestion to remove from: wmonk/create-react-app-typescript#74 Change tsconfig.json compiler target to es7 With target set to es6, was receiving error: ERROR in /home/jthetzel/src/react-mapbox-gl/src/layer.ts (206,22): error TS2339: Property 'includes' does not exist on type 'number[]'. Suggestion to try es7: PatrickJS/PatrickJS-starter#931 (comment) Removing carets from devDependencies Presume this is preferred, as master branch does not use carets.
@rvalimaki 's suggestion worked for me, just had to remember to Reload Window for the changes to take effect. |
Remove rootDir from example/tsconfig.json Inclusion was causing TS6059 'rootDir' is expected to contain all source files error. Suggestion to remove from: wmonk/create-react-app-typescript#74 Change tsconfig.json compiler target to es7 With target set to es6, was receiving error: ERROR in /home/jthetzel/src/react-mapbox-gl/src/layer.ts (206,22): error TS2339: Property 'includes' does not exist on type 'number[]'. Suggestion to try es7: PatrickJS/PatrickJS-starter#931 (comment) Removing carets from devDependencies Presume this is preferred, as master branch does not use carets.
Remove rootDir from example/tsconfig.json Inclusion was causing TS6059 'rootDir' is expected to contain all source files error. Suggestion to remove from: wmonk/create-react-app-typescript#74 Change tsconfig.json compiler target to es7 With target set to es6, was receiving error: ERROR in /home/jthetzel/src/react-mapbox-gl/src/layer.ts (206,22): error TS2339: Property 'includes' does not exist on type 'number[]'. Suggestion to try es7: PatrickJS/PatrickJS-starter#931 (comment) Removing carets from devDependencies Presume this is preferred, as master branch does not use carets.
Remove rootDir from example/tsconfig.json Inclusion was causing TS6059 'rootDir' is expected to contain all source files error. Suggestion to remove from: wmonk/create-react-app-typescript#74 Change tsconfig.json compiler target to es7 With target set to es6, was receiving error: ERROR in /home/jthetzel/src/react-mapbox-gl/src/layer.ts (206,22): error TS2339: Property 'includes' does not exist on type 'number[]'. Suggestion to try es7: PatrickJS/PatrickJS-starter#931 (comment) Removing carets from devDependencies Presume this is preferred, as master branch does not use carets.
Remove rootDir from example/tsconfig.json Inclusion was causing TS6059 'rootDir' is expected to contain all source files error. Suggestion to remove from: wmonk/create-react-app-typescript#74 Change tsconfig.json compiler target to es7 With target set to es6, was receiving error: ERROR in /home/jthetzel/src/react-mapbox-gl/src/layer.ts (206,22): error TS2339: Property 'includes' does not exist on type 'number[]'. Suggestion to try es7: PatrickJS/PatrickJS-starter#931 (comment) Removing carets from devDependencies Presume this is preferred, as master branch does not use carets.
Remove rootDir from example/tsconfig.json Inclusion was causing TS6059 'rootDir' is expected to contain all source files error. Suggestion to remove from: wmonk/create-react-app-typescript#74 Change tsconfig.json compiler target to es7 With target set to es6, was receiving error: ERROR in /home/jthetzel/src/react-mapbox-gl/src/layer.ts (206,22): error TS2339: Property 'includes' does not exist on type 'number[]'. Suggestion to try es7: PatrickJS/PatrickJS-starter#931 (comment) Removing carets from devDependencies Presume this is preferred, as master branch does not use carets.
Remove rootDir from example/tsconfig.json Inclusion was causing TS6059 'rootDir' is expected to contain all source files error. Suggestion to remove from: wmonk/create-react-app-typescript#74 Change tsconfig.json compiler target to es7 With target set to es6, was receiving error: ERROR in /home/jthetzel/src/react-mapbox-gl/src/layer.ts (206,22): error TS2339: Property 'includes' does not exist on type 'number[]'. Suggestion to try es7: PatrickJS/PatrickJS-starter#931 (comment) Removing carets from devDependencies Presume this is preferred, as master branch does not use carets.
[*] bug report
[ ] feature request
[ ] question about the decisions made in the repository
report a bug
I got following error.
Property 'includes' does not exist on type 'string[]'.
After this commit, when I use 'Array.prototype.includes()' I got above error.
No errors.
Angular version: 2.0.0-rc5
Node v6.2.2
NPM v 3.9.5
The text was updated successfully, but these errors were encountered: