'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'

Multi tool use
Multi tool use

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















            o3QcE67vwwEsU9Rj45,L0EqLb9AD1ke 7Z7 xo
            3i6747,p8ueIvWXWJxAu 2g8fbMMmYk07 AJHqWgZvZyhsSaFMU4

            Popular posts from this blog

            1928 у кіно

            Захаров Федір Захарович

            IntelliJ IDEA underlines variables when using += in JAVA2019 Community Moderator ElectionHow can I permanently enable line numbers in IntelliJ?Is Java “pass-by-reference” or “pass-by-value”?When to use LinkedList over ArrayList in Java?How do I generate random integers within a specific range in Java?What is the scope of variables in JavaScript?How to determine if variable is 'undefined' or 'null'?How do I convert a String to an int in Java?IntelliJ inspection gives “Cannot resolve symbol” but still compiles codeCreating a memory leak with JavaHow to see JavaDoc in IntelliJ IDEA?