-
Notifications
You must be signed in to change notification settings - Fork 559
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
Typescript error when using lib-storage upload #2085
Comments
@inian this doesnt seem like a bug with the SDK, the idea is to bring in the same types that S3 says it can take. To expand those types we'd need to expand the putObject types and that carries a bunch of additional work (mostly around testing) to make sure everything works as intended. Also, sorry about having to include DOM types in the tsconfig! We made this choice internally, i know its not ideal and I'm happy to revisit if its a huge issue with the community. I see you linked #1688 where I touched on this. Since this is just a type error, to get rid of the typescript error in your code immediately you can do something like:
I know its a bit ugly, but we probably wont be able to prioritize adding NodeJS.ReadableStream as a valid data input type. |
@inian you can remove
This will mean you don't need to do any casting nor have to risk false negatives due to interfaces and globals defined in the DOM lib :) |
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs and link to relevant comments in this thread. |
Describe the bug
In the above code example, data.file is of type NodeJS.ReadableStream.
When I pass that to Upload, it errors out with the following error
I think this is happening because it is taking in the type definition of WHATWG streams and trying to match with NodeJS.Readable stream.
I had to include DOM types in my tsconfig lib because of this. If I remove "DOM" types from tsconfig, I am getting other errors like this
How do I force typescript to assume it is a NodeJS.Readable stream here and not a WHATWG stream?
I was able to fix the error by changing the type definition here to
NodeJS.ReadableStream
instead ofReadableStream
and adding "DOM" to my tsconfig lib.Your environment
SDK version number
@aws-sdk/lib-storage@3.6.1
Is the issue in the browser/Node.js/ReactNative?
Node.js
Details of the browser/Node.js/ReactNative version
Node v12.20.2
The text was updated successfully, but these errors were encountered: