Skip to content

Typing Issue: Type mismatch with Writable #575

@Bene-Graham

Description

@Bene-Graham

Issue
I see the #549 changed the return types for createInputStream(). This is not longer type compatible with nodeJS pipe method.

Argument of type 'Writable' is not assignable to parameter of type 'WritableStream'. Property 'writable' is missing in type 'Writable'.

I also see some else is having a similar problem with the Buffer interface #559

Workaround
A temporary work around is for be to cast the return type to a Writable from the NodeJS stream library.

import { Writable } from "stream";
...
...
fs.createReadStream(objFile.path).pipe(workbook.xlsx.createInputStream() as Writable)
                    .on("done", () => {
                        resolve(workbook);
                    })
                    .on("error", (error2) => {
                        reject(error2);
                    });

To me this is not optimal since if the return type ever does change TypeScript won't find it as a error at compile time and would only be caught a run time.

Closing
I can create a PR this to revert it back to what it was. Unfortunately I have not used exceljs in a browser so I am not sure what issue this was causing. Not sure if @jloveridge could chime in on the browser side of things?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions