error TS2304: Cannot find name 'File'.
AliakseiBychyk opened this issue ยท 8 comments
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;
~~~~~~~~~~~~~~
Interesting, I've not see this problem. What version of TypeScript are you using?
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'.
@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?
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.
@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
.
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?