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 'find' does not exist on type #29473

Closed
mariohmol opened this issue Jan 18, 2019 · 5 comments
Closed

Property 'find' does not exist on type #29473

mariohmol opened this issue Jan 18, 2019 · 5 comments
Labels
External Relates to another program, environment, or user action which we cannot control.

Comments

@mariohmol
Copy link

mariohmol commented Jan 18, 2019

"typescript": "^3.2.2"

Search Terms: Property 'find' does not exist on type

Code

https://github.com/mariohmol/gherkin/blob/master/index.ts#L17

const found = c.students.find(s => s === student);

Running tsc index.ts

Config:
https://github.com/mariohmol/gherkin/blob/master/tsconfig.json#L8

Expected behavior: Compile sucessfully

Actual behavior:
https://travis-ci.org/mariohmol/gherkin/jobs/481149988#L446

index.ts:17:34 - error TS2339: Property 'find' does not exist on type 'Student[]'.

17         const found = c.students.find(s => s === student); 

Playground Link: https://github.com/mariohmol/gherkin

Related Issues: #6945

@DanielRosenwasser
Copy link
Member

Worked for me when I cloned it, but with issues around document not being defined since you're not including the DOM:

Cannot find name 'document'. Do you need to change your target library? Try changing the `lib` compiler option to include 'dom'.

@mariohmol
Copy link
Author

Thanks for quick response!

I separated the class from the rest:

https://travis-ci.org/mariohmol/gherkin/jobs/481159659#L447
https://github.com/mariohmol/gherkin/blob/master/classes.ts

same issue =(

@MartinJohns
Copy link
Contributor

MartinJohns commented Jan 18, 2019

@mariohmol You're using the TypeScript compiler wrong.

https://travis-ci.org/mariohmol/gherkin/jobs/481159659#L447

When you invoke the tsc compiler by providing a list of filenames, then the tsconfig.json will NOT be used. You need to specify all compiler flags you want yourself then. As a result the default compiler flags are used and an old ES version is targeted that does not provide Array.find.

From the tsconfig documentation:

When input files are specified on the command line, tsconfig.json files are ignored.

@DanielRosenwasser likely didn't follow your step to invoke tsc index.ts when trying to reproduce this issue.

@mariohmol
Copy link
Author

@MartinJohns you rocks!

@DanielRosenwasser DanielRosenwasser added the External Relates to another program, environment, or user action which we cannot control. label Jan 19, 2019
@thalles-victor
Copy link

Try run:

  npm install @types/node --save-dev

in your project.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
External Relates to another program, environment, or user action which we cannot control.
Projects
None yet
Development

No branches or pull requests

4 participants