Skip to content
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

Type incompatibility for writeFile #1022

Open
michaelfaith opened this issue Apr 3, 2024 · 1 comment
Open

Type incompatibility for writeFile #1022

michaelfaith opened this issue Apr 3, 2024 · 1 comment

Comments

@michaelfaith
Copy link

michaelfaith commented Apr 3, 2024

Originally reported in the webpack repo: webpack/webpack#18242 this appears to actually be a broken type here. When trying to assign an IFs object to a prop of fs type, we get an error about writeFile and the WriteFileOptions type not matching. Seems like the overloads are off a bit.

Type 'IFs' is not assignable to type 'OutputFileSystem'.
  Types of property 'writeFile' are incompatible.
    Type '{ (id: TFileId, data: TData, callback: TCallback<void>): any; (id: TFileId, data: TData, options: string | IWriteFileOptions, callback: TCallback<...>): any; }' is not assignable to type 'WriteFile'.
      Types of parameters 'callback' and 'options' are incompatible.
        Type 'WriteFileOptions' is not assignable to type 'TCallback<void>'.
          Type 'null' is not assignable to type 'TCallback<void>'.ts(2322)
(property) Compiler.outputFileSystem: OutputFileSystem | null

Tested with the latest version of memfs (4.8.1)

@michaelfaith michaelfaith changed the title TypeScript incompatibility for writeFile Type incompatibility for writeFile Apr 3, 2024
@G-Rath
Copy link
Collaborator

G-Rath commented Apr 3, 2024

PRs improving the types are always welcomed!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants