I am trying to create a simple class implementing
I am not sure exactly what I am doing wrong. Any hint?
node
: 16.17.0
@types/node
: 16.11.64
typescript
: 4.8.3
CodePudding user response:
You need to declare the _write
method outside of the constructor.
class MyWritable extends Writable {
constructor() {
super({ objectMode: true });
}
// moved outside the constructor function.
_write(chunk: any, encoding: BufferEncoding, callback: () => void) {
//...
}
}
Which works without errors. See Playground