memfs
memfs copied to clipboard
Type incompatibility for `writeFile`
Originally reported in the webpack
repo: https://github.com/webpack/webpack/issues/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)
PRs improving the types are always welcomed!