-
Notifications
You must be signed in to change notification settings - Fork 2
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
Interface 'SrcOptions' incorrectly extends interface 'Options' #1
Comments
Does this only happen when you update to TS2 and the node typings? |
Update typescript is needed to avoid compile errors with new versions of node typings (new versions of node typings adds support for non nullable types). The problem is that after this commit (2016-11-05) the read property of node ReadableOptions interface (parent type of SrcOptions) conflicts with SrcOptions read property type. |
@blakeembrey I can't find the |
@felixfbecker See https://nodejs.org/api/stream.html#stream_implementing_a_readable_stream for the |
@blakeembrey Afaik you should implement these when subclassing |
Reviewing the |
@felixfbecker Read the options signature and the "Simplified Constructor approach":
|
The method you need to implement is actually called |
@felixfbecker The code works in production because node.js checks for a function type: https://github.com/nodejs/node/blob/1f45d7aa41291383ce63cca5f80fd2a2a73d7603/lib/_stream_readable.js#L113. If it ever changed to an error, I think |
We could do a union type |
Sure, that seems reasonable. I just realised |
Hm, then you are right, a difference type would be best for this... |
This don't work.
|
I encountered this issue as well. After some looking through the vinyl-fs code I found out that neither Also, if there really was a reason for it to extend through.Options, then that reason could only be that SrcOptions is passed to a function that accepts through.Options despite it containing a 'read' property that isn't of the expected type. That would be a serious bug that should be fixed in vinyl-fs itself and I doubt this is the case. |
Functionality: - Remove SrcOptions inheritance of through.Options Testing done: manual [Issue](typed-typings#1)
Steps to reproduce.
npm install
.npm i typescript@^2.0.10 -D
.typings i env~node -SG
.npm run build
andnpm run test
.This is the line that causes the error.
This is because
SrcOptions
extendsthrough.Options
that extendsstream.DuplexOptions
that extendsReadableOptions
that definesread
property asread?: (size?: number) => any;
.The text was updated successfully, but these errors were encountered: