You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In below code, stream.end() should be compiled as fs.WriteStream extends stream.Writable which has end() method. However, this won't be compiled without asInstanceOf[].
object Main {
def main(args: Array[String]): Unit = {
val stream = typings.node.fsMod.createWriteStream("output.txt")
// stream.end() // value end is not a member of typings.node.fsMod.WriteStream
stream.asInstanceOf[typings.node.streamMod.Writable].end()
}
}
The corresponding d.ts should be this. I'm not sure why ScalablyTyped cannot resolve this extends, but maybe import * as stream from 'node:stream' is the case.
The text was updated successfully, but these errors were encountered:
unarist
changed the title
When import node:fs, WriteStream not extends Writable
In @types/node, fs.WriteStream does not extend stream.Writable
Sep 15, 2023
I'm aware there has been come imperfections with those classes. One case I remember in particular is that deep in that complicated hierarchy there is a Duplex class which extends what ST needs to consider two classes. This is not permitted, so one of them is dropped.
This may be something different though, I'll look into eventually. For now the cast is a good workaround
In below code,
stream.end()
should be compiled asfs.WriteStream
extendsstream.Writable
which hasend()
method. However, this won't be compiled withoutasInstanceOf[]
.ST generated source:
The corresponding d.ts should be this. I'm not sure why ScalablyTyped cannot resolve this
extends
, but maybeimport * as stream from 'node:stream'
is the case.https://github.com/DefinitelyTyped/DefinitelyTyped/blob/61694a446616874377bc7b87b8644d8eed2da19a/types/node/v18/fs.d.ts#L450
https://github.com/DefinitelyTyped/DefinitelyTyped/blob/61694a446616874377bc7b87b8644d8eed2da19a/types/node/v18/fs.d.ts#L22
https://github.com/DefinitelyTyped/DefinitelyTyped/blob/61694a446616874377bc7b87b8644d8eed2da19a/types/node/v18/stream.d.ts#L1455-L1457
build configuration
plugins.sbt
build.sbt
The text was updated successfully, but these errors were encountered: