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

error TS2304: Cannot find name 'File'. #9

Closed
AliakseiBychyk opened this issue Apr 10, 2019 · 8 comments
Closed

error TS2304: Cannot find name 'File'. #9

AliakseiBychyk opened this issue Apr 10, 2019 · 8 comments

Comments

@AliakseiBychyk
Copy link

AliakseiBychyk commented Apr 10, 2019

I faced an issue with the package when executed ts build:

C:\...\...\node_modules\typescript\bin\tsc
node_modules/ibm-cloud-sdk-core/lib/content-type.d.ts:4:35 - error TS2304: Cannot find name 'File'.

4     fromFilename: (file: String | File | ReadableStream | Buffer | FileObject) => string;
                                    ~~~~

node_modules/ibm-cloud-sdk-core/lib/content-type.d.ts:4:42 - error TS2304: Cannot find name 'ReadableStream'.

4     fromFilename: (file: String | File | ReadableStream | Buffer | FileObject) => string;
                                           ~~~~~~~~~~~~~~

@dpopp07
Copy link
Member

dpopp07 commented Apr 10, 2019

Interesting, I've not see this problem. What version of TypeScript are you using?

@AliakseiBychyk
Copy link
Author

AliakseiBychyk commented Apr 11, 2019

TypeScript v.3.4.2
I found that someone already described the similar issue on Stackoverflow: https://stackoverflow.com/questions/55340159/receiving-ts2304-cannot-find-name-file-ts2304-cannot-find-name-readablest

Previously I used 'watson-developer-cloud' v.3.18.1 it had build-in lib, but newer version 4.0.1 has dependency on 'ibm-cloud-sdk-core'.

@dpopp07
Copy link
Member

dpopp07 commented Apr 12, 2019

@AliakseiBychyk I tried installing v3.4.2 and creating a sample project depending on v4.0.1. I am not getting any errors. Will you list some specific steps I can follow to reproduce this issue?

@alexpls
Copy link
Contributor

alexpls commented Apr 16, 2019

ReadableStream and File types will not be imported by default unless the dom library has been included in your TypeScript config.

@AliakseiBychyk, try adding this to your tsconfig.json:

{
  ...
  "compilerOptions": {
    "lib": [
      ...
      "dom"
    ]
  }
}

As a side note, I'm not convinced that using the dom library's ReadableStream was the intention here, since the rest of this package uses the NodeJS.ReadableStream type instead. I'm happy to make a PR to change this to NodeJS.ReadableStream if you agree.

@AliakseiBychyk
Copy link
Author

AliakseiBychyk commented Apr 16, 2019

@alexpls Thanks, actually --lib dom in compiler options fixed the problem.
Since my app runs only on server-side, I didn't include 'dom' to the ts compiler options. It seems to me reasonable to change ReadableStream type to NodeJS.ReadableStream.

@dpopp07
Copy link
Member

dpopp07 commented Apr 16, 2019

@alexpls I think that's a good idea, feel free to open that PR. Thanks

@alexpls
Copy link
Contributor

alexpls commented Apr 16, 2019

Glad to hear it's working @AliakseiBychyk!

@dpopp07 I've opened up a PR to use NodeJS.ReadableStream instead of DOM ReadableStream.

I reckon this issue can be closed now, right?

@dpopp07
Copy link
Member

dpopp07 commented Apr 17, 2019

Resolved with #13

Thanks @alexpls

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

3 participants