Skip to content

Property 'find' does not exist on type 'Token[]'. #928

Description

@SeanningTatum

Typescript recognize es6 array functions

function findDate(tokenArray: Array<Token>) {

  // Find Month in sentence
  const token: Token = tokenArray.find((token) => {
    const month = token.text.content.toUpperCase()

    return MONTHS.includes(month)
  })

  console.log(token)

  return ''
}

I've tried creating a tsconfig.json but still doesn't work

{
  "compilerOptions": {
    "module": "es6",
    "lib": [ "es2017", "dom" ]
  }
}

Activity

  1. fhinkel commented on Nov 21, 2018

    @fhinkel
    Contributor

    Hi, thanks for raising the issue. For which sample is this? It should work if you use "target": "es6" in the config.

  2. SeanningTatum commented on Nov 28, 2018

    @SeanningTatum
    Author

    @fhinkel Hi this is on the typescript sample. I've adjusted my tsconfig.json to

    {
    "compilerOptions": {
        "target": "es6",
        "sourceMap": true
      }
    }
    

    But I still get a compilation error Property 'includes' does not exist on type 'String[]' and Property 'find' does not exist on type 'Token[]'.

  3. fhinkel commented on Dec 9, 2018

    @fhinkel
    Contributor

    @JustinBeckwith Could you have a look at the typescript samples? Thanks

  4. JustinBeckwith commented on Dec 10, 2018

    @JustinBeckwith
    Contributor

    Greetings @SeanningTatum! I can't find the exact code you're trying anywhere in the repo, or any of the other repositories we have here. Could you share the specific file where you're seeing this stuff? Including the url?

    If all else fails, a complete example (that I can run) would be super, super helpful :)

  5. SeanningTatum commented on Dec 12, 2018

    @SeanningTatum
    Author

    @JustinBeckwith I was running the with-typescript example. And sorry I can't provide you a complete example.

  6. JustinBeckwith commented on Dec 12, 2018

    @JustinBeckwith
    Contributor

    Can you point us towards the with-typescript sample? Can you give me a url?

  7. fhinkel commented on Dec 17, 2018

    @fhinkel
    Contributor

    We updated the sample. Could you try again? Thanks!

  8. fhinkel commented on Feb 6, 2019

    @fhinkel
    Contributor

    Closing this due to inactivity. Let us know if the update didn't fix it and we can reopen the issue.

  9. added a commit that references this issue on Nov 16, 2022
  10. added a commit that references this issue on Nov 16, 2022
  11. added a commit that references this issue on Nov 17, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions