Skip to content
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

Closed
monad98 opened this issue Aug 30, 2016 · 6 comments
Closed

Property 'includes' does not exist on type 'string[]'. #931

monad98 opened this issue Aug 30, 2016 · 6 comments

Comments

@monad98
Copy link

monad98 commented Aug 30, 2016

  • I'm submitting a ...
    [*] bug report
    [ ] feature request
    [ ] question about the decisions made in the repository
  • Do you want to request a feature or report a bug?
    report a bug
  • What is the current behavior?
    I got following error.
    Property 'includes' does not exist on type 'string[]'.
  • If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem
    After this commit, when I use 'Array.prototype.includes()' I got above error.
  • What is the expected behavior?
    No errors.
  • Please tell us about your environment:
    Angular version: 2.0.0-rc5
    Node v6.2.2
    NPM v 3.9.5
@rvalimaki
Copy link

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.

@rvalimaki
Copy link

Okay, to overcome the issue, I needed to set tsconfig.json compilerOptions.lib from "es6" to "es7" as follows:

"lib": [
  "dom",
  "es7"
],

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.

@KhaledElAnsari
Copy link

KhaledElAnsari commented Jan 23, 2017

any updates on this?

btw I did a different approach to do what includes() do

let targetClasses: Array<string> = ["open_time", "close_time"];
let isThere: boolean = targetClasses.some(cls => (<HTMLElement>event.target).classList.contains(cls));
...

@rvalimaki
Copy link

rvalimaki commented Jan 23, 2017

@KhaledElAnsari

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.

@karkokat
Copy link

karkokat commented Mar 8, 2017

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.

jthetzel added a commit to jthetzel/react-mapbox-gl that referenced this issue Sep 28, 2017
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)
jthetzel added a commit to jthetzel/react-mapbox-gl that referenced this issue Oct 3, 2017
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)
jthetzel added a commit to jthetzel/react-mapbox-gl that referenced this issue Oct 4, 2017
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.
jthetzel added a commit to jthetzel/react-mapbox-gl that referenced this issue Oct 4, 2017
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.
@leotm
Copy link

leotm commented Nov 22, 2018

@rvalimaki 's suggestion worked for me, just had to remember to Reload Window for the changes to take effect.

mashtechk added a commit to mashtechk/react-mapbox-gl that referenced this issue Jan 23, 2021
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.
preecedavid pushed a commit to preecedavid/React-Mapbox-gl that referenced this issue Mar 7, 2022
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.
preecedavid pushed a commit to preecedavid/React-Mapbox-gl that referenced this issue Apr 28, 2022
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.
kevin11290 pushed a commit to kevin11290/mar28 that referenced this issue Mar 28, 2023
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.
marcopeakdev pushed a commit to marcopeakdev/react-mapbox-exam that referenced this issue Oct 12, 2023
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.
crown0128 added a commit to crown0128/typescript-react-mapbox that referenced this issue Oct 29, 2023
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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants