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

[5.91.0] "Fixed fs types" breaks outputFileSystem compatibility with memfs #18242

Closed
birdofpreyru opened this issue Mar 25, 2024 · 8 comments
Closed

Comments

@birdofpreyru
Copy link

Bug report

What is the current behavior?

After Webpack upgrade from v5.90.3 to 5.91.0 in an existing project, the TypeScript does not allow the code given in Custom File Systems docs because of typing conflict mismatch:

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

I guess the change for "Fixed fs types" led to a regression.

If the current behavior is a bug, please provide the steps to reproduce.

What is the expected behavior?

Other relevant information:
webpack version:
Node.js version:
Operating System:
Additional tools:

@birdofpreyru
Copy link
Author

This is a working workaround:

compiler.outputFileSystem = fs as typeof compiler.outputFileSystem;

@alexander-akait
Copy link
Member

Please open an issue in memfs, they have broken fs types, I wrote them, but no feedback, I can't fix it here, sorry

@alexander-akait
Copy link
Member

You can make sure to use this:

const fs = require("fs");
const fs1 = require("graceful-fs");

compiler.outputFileSystem = fs;
compiler.outputFileSystem = fs1;

but problems only with memfs, because some methods have wrong types

@alexander-akait
Copy link
Member

Anyway feel free to feedback

@birdofpreyru
Copy link
Author

I created this issue mostly to make sure you've noticed this problem, and you know that example in Webpack docs does not really work as is now. For my purposes, just forcing the assignment via TypeScript casting is fine, so I don't feel any urge to do anything else about it.

@alexander-akait
Copy link
Member

Yeah, memfs works fine with webpack, we have a lot of tests, just the types problem

@michaelfaith
Copy link

I just hit this issue as well. It doesn't look like this has been reported in the memfs repo. @birdofpreyru were you planning to file that?

@birdofpreyru
Copy link
Author

Nah @michaelfaith , I got distracted by different stuff and never reported it. Please report it there if you have a moment :)

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

3 participants