Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

149
Views
stream.write Esta expresión no se puede llamar

Estoy tratando de escribir una función que tome un flujo grabable (createWriteStream) o process.stdout/.stderr pero mecanografiado sigue arrojando este error. El error desaparece cuando hago una verificación de tipo condicional.

 import { createWriteStream, WriteStream } from 'fs' const writehello = (stream: NodeJS.WriteStream & { fd: 1 } | WriteStream) => stream.write('hello\n') // error writehello(process.stdout) writehello(createWriteStream('/tmp/al.txt'))

Mensaje de error en la línea 3

 error TS2349: This expression is not callable. Each member of the union type '{ (buffer: string | Uint8Array, cb?: ((err?: Error | undefined) => void) | undefined): boolean; (str: string | Uint8Array, encoding?: BufferEncoding | undefined, cb?: ((err?: Error | undefined) => void) | undefined): boolean; } | { ...; }' has signatures, but none of those signatures are compatible with each other.
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Tanto NodeJS.WriteStream como WriteStream sobrecargan el método write() , pero usan firmas diferentes, lo que genera el error que está viendo.

En lugar de definir el tipo de unión entre estos dos tipos, puede definir el tipo del parámetro de stream usando Writable , que se extiende por ambos:

 import { createWriteStream } from 'fs' import { Writable } from 'stream' const writehello = (stream: Writable) => stream.write('hello\n') writehello(process.stdout) writehello(createWriteStream('/tmp/al.txt'))
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!