'includes' does not exists on type 'string[]' in TypeScript [duplicate]2019 Community Moderator ElectionProperty 'includes' does not exist on type 'string[]'How do I check if an array includes an object in JavaScript?How do I check if an array includes an object in JavaScript?Checking if a key exists in a JavaScript object?Sort array of objects by string property valueCheck if a value exists in an array in RubyWhat is TypeScript and why would I use it in place of JavaScript?Type definition in object literal in TypeScriptInterface type check with TypescriptTypeScript Converting a String to a numberHow to implement class constants in typescript?TS2339: Property 'includes' does not exist on type 'string'

Does the US political system, in principle, allow for a no-party system?

Was it really inappropriate to write a pull request for the company I interviewed with?

If nine coins are tossed, what is the probability that the number of heads is even?

How do you make a gun that shoots melee weapons and/or swords?

Translation of 答えを知っている人はいませんでした

Why does Central Limit Theorem break down in my simulation?

When an outsider describes family relationships, which point of view are they using?

What does *dead* mean in *What do you mean, dead?*?

Gomel chasadim tovim - are there bad chasadim?

Can the Witch Sight warlock invocation see through the Mirror Image spell?

Having the player face themselves after the mid-game

Converting from "matrix" data into "coordinate" data

What is the purpose of a disclaimer like "this is not legal advice"?

Is "cogitate" used appropriately in "I cogitate that success relies on hard work"?

Should we avoid writing fiction about historical events without extensive research?

Did Amazon pay $0 in taxes last year?

Why restrict private health insurance?

Is there a logarithm base for which the logarithm becomes an identity function?

Traveling to heavily polluted city, what practical measures can I take to minimize impact?

Rationale to prefer local variables over instance variables?

Playing a 7-string guitar song on a 6-string guitar

Are all players supposed to be able to see each others' character sheets?

What sort of fish is this

Called into a meeting and told we are being made redundant (laid off) and "not to share outside". Can I tell my partner?



'includes' does not exists on type 'string[]' in TypeScript [duplicate]



2019 Community Moderator ElectionProperty 'includes' does not exist on type 'string[]'How do I check if an array includes an object in JavaScript?How do I check if an array includes an object in JavaScript?Checking if a key exists in a JavaScript object?Sort array of objects by string property valueCheck if a value exists in an array in RubyWhat is TypeScript and why would I use it in place of JavaScript?Type definition in object literal in TypeScriptInterface type check with TypescriptTypeScript Converting a String to a numberHow to implement class constants in typescript?TS2339: Property 'includes' does not exist on type 'string'










0
















This question already has an answer here:



  • Property 'includes' does not exist on type 'string[]'

    2 answers



From this question and the accepted answer, I know that there is an methode to check if an array includes an object in JavaScript by using this line of code:




> ['joe', 'jane', 'mary'].includes('jane');
true



However if I use the same code in TypeScript I've got this error:




Property includes does not exist on type string[].




  1. Why gives the compiler this error? I'm expecting that everything that is available in JS, is available in TS.

  2. How could I solve this error without changing the code? It must be working on ES5.









share|improve this question















marked as duplicate by H. Pauwelyn, Community Mar 6 at 14:04


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.


















  • @Baboo_: It's not a duplicate because my question goes about TypeScript and not about JavaScript like the link you provided!

    – H. Pauwelyn
    Mar 6 at 13:59











  • I missed copied, the link you provided is the one I wanted to provide ;)

    – Baboo_
    Mar 6 at 14:04















0
















This question already has an answer here:



  • Property 'includes' does not exist on type 'string[]'

    2 answers



From this question and the accepted answer, I know that there is an methode to check if an array includes an object in JavaScript by using this line of code:




> ['joe', 'jane', 'mary'].includes('jane');
true



However if I use the same code in TypeScript I've got this error:




Property includes does not exist on type string[].




  1. Why gives the compiler this error? I'm expecting that everything that is available in JS, is available in TS.

  2. How could I solve this error without changing the code? It must be working on ES5.









share|improve this question















marked as duplicate by H. Pauwelyn, Community Mar 6 at 14:04


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.


















  • @Baboo_: It's not a duplicate because my question goes about TypeScript and not about JavaScript like the link you provided!

    – H. Pauwelyn
    Mar 6 at 13:59











  • I missed copied, the link you provided is the one I wanted to provide ;)

    – Baboo_
    Mar 6 at 14:04













0












0








0









This question already has an answer here:



  • Property 'includes' does not exist on type 'string[]'

    2 answers



From this question and the accepted answer, I know that there is an methode to check if an array includes an object in JavaScript by using this line of code:




> ['joe', 'jane', 'mary'].includes('jane');
true



However if I use the same code in TypeScript I've got this error:




Property includes does not exist on type string[].




  1. Why gives the compiler this error? I'm expecting that everything that is available in JS, is available in TS.

  2. How could I solve this error without changing the code? It must be working on ES5.









share|improve this question

















This question already has an answer here:



  • Property 'includes' does not exist on type 'string[]'

    2 answers



From this question and the accepted answer, I know that there is an methode to check if an array includes an object in JavaScript by using this line of code:




> ['joe', 'jane', 'mary'].includes('jane');
true



However if I use the same code in TypeScript I've got this error:




Property includes does not exist on type string[].




  1. Why gives the compiler this error? I'm expecting that everything that is available in JS, is available in TS.

  2. How could I solve this error without changing the code? It must be working on ES5.




This question already has an answer here:



  • Property 'includes' does not exist on type 'string[]'

    2 answers







arrays typescript ecma






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Mar 6 at 14:00







H. Pauwelyn

















asked Mar 6 at 13:52









H. PauwelynH. Pauwelyn

5,856184987




5,856184987




marked as duplicate by H. Pauwelyn, Community Mar 6 at 14:04


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.









marked as duplicate by H. Pauwelyn, Community Mar 6 at 14:04


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.














  • @Baboo_: It's not a duplicate because my question goes about TypeScript and not about JavaScript like the link you provided!

    – H. Pauwelyn
    Mar 6 at 13:59











  • I missed copied, the link you provided is the one I wanted to provide ;)

    – Baboo_
    Mar 6 at 14:04

















  • @Baboo_: It's not a duplicate because my question goes about TypeScript and not about JavaScript like the link you provided!

    – H. Pauwelyn
    Mar 6 at 13:59











  • I missed copied, the link you provided is the one I wanted to provide ;)

    – Baboo_
    Mar 6 at 14:04
















@Baboo_: It's not a duplicate because my question goes about TypeScript and not about JavaScript like the link you provided!

– H. Pauwelyn
Mar 6 at 13:59





@Baboo_: It's not a duplicate because my question goes about TypeScript and not about JavaScript like the link you provided!

– H. Pauwelyn
Mar 6 at 13:59













I missed copied, the link you provided is the one I wanted to provide ;)

– Baboo_
Mar 6 at 14:04





I missed copied, the link you provided is the one I wanted to provide ;)

– Baboo_
Mar 6 at 14:04












1 Answer
1






active

oldest

votes


















1














Includes is defined in the lib.es2016.array.include.d.ts since it is part of the es2016 standard. You can include this lib in your tsconfig but you have to provide your own polyfil for the method:




"compilerOptions":
"target": "es5",
"lib": [
"dom",
"scripthost",
"es5",
"es2016.array.include"
]




You can also provide the polyfill by assigning Array.prototype.include if your runtime does not provide this method on array (you can get a polyfill from here for example)






share|improve this answer





























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    1














    Includes is defined in the lib.es2016.array.include.d.ts since it is part of the es2016 standard. You can include this lib in your tsconfig but you have to provide your own polyfil for the method:




    "compilerOptions":
    "target": "es5",
    "lib": [
    "dom",
    "scripthost",
    "es5",
    "es2016.array.include"
    ]




    You can also provide the polyfill by assigning Array.prototype.include if your runtime does not provide this method on array (you can get a polyfill from here for example)






    share|improve this answer



























      1














      Includes is defined in the lib.es2016.array.include.d.ts since it is part of the es2016 standard. You can include this lib in your tsconfig but you have to provide your own polyfil for the method:




      "compilerOptions":
      "target": "es5",
      "lib": [
      "dom",
      "scripthost",
      "es5",
      "es2016.array.include"
      ]




      You can also provide the polyfill by assigning Array.prototype.include if your runtime does not provide this method on array (you can get a polyfill from here for example)






      share|improve this answer

























        1












        1








        1







        Includes is defined in the lib.es2016.array.include.d.ts since it is part of the es2016 standard. You can include this lib in your tsconfig but you have to provide your own polyfil for the method:




        "compilerOptions":
        "target": "es5",
        "lib": [
        "dom",
        "scripthost",
        "es5",
        "es2016.array.include"
        ]




        You can also provide the polyfill by assigning Array.prototype.include if your runtime does not provide this method on array (you can get a polyfill from here for example)






        share|improve this answer













        Includes is defined in the lib.es2016.array.include.d.ts since it is part of the es2016 standard. You can include this lib in your tsconfig but you have to provide your own polyfil for the method:




        "compilerOptions":
        "target": "es5",
        "lib": [
        "dom",
        "scripthost",
        "es5",
        "es2016.array.include"
        ]




        You can also provide the polyfill by assigning Array.prototype.include if your runtime does not provide this method on array (you can get a polyfill from here for example)







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Mar 6 at 13:57









        Titian Cernicova-DragomirTitian Cernicova-Dragomir

        69.3k34765




        69.3k34765















            Popular posts from this blog

            Save data to MySQL database using ExtJS and PHP [closed]2019 Community Moderator ElectionHow can I prevent SQL injection in PHP?Which MySQL data type to use for storing boolean valuesPHP: Delete an element from an arrayHow do I connect to a MySQL Database in Python?Should I use the datetime or timestamp data type in MySQL?How to get a list of MySQL user accountsHow Do You Parse and Process HTML/XML in PHP?Reference — What does this symbol mean in PHP?How does PHP 'foreach' actually work?Why shouldn't I use mysql_* functions in PHP?

            Compiling GNU Global with universal-ctags support Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 23, 2019 at 23:30 UTC (7:30pm US/Eastern) Data science time! April 2019 and salary with experience The Ask Question Wizard is Live!Tags for Emacs: Relationship between etags, ebrowse, cscope, GNU Global and exuberant ctagsVim and Ctags tips and trickscscope or ctags why choose one over the other?scons and ctagsctags cannot open option file “.ctags”Adding tag scopes in universal-ctagsShould I use Universal-ctags?Universal ctags on WindowsHow do I install GNU Global with universal ctags support using Homebrew?Universal ctags with emacsHow to highlight ctags generated by Universal Ctags in Vim?

            Add ONERROR event to image from jsp tldHow to add an image to a JPanel?Saving image from PHP URLHTML img scalingCheck if an image is loaded (no errors) with jQueryHow to force an <img> to take up width, even if the image is not loadedHow do I populate hidden form field with a value set in Spring ControllerStyling Raw elements Generated from JSP tagds with Jquery MobileLimit resizing of images with explicitly set width and height attributeserror TLD use in a jsp fileJsp tld files cannot be resolved