gulpjs / vinyl

Virtual file format.
MIT License
1.28k stars 107 forks source link

Clarify the type of `options.stat` #121

Closed demurgos closed 7 years ago

demurgos commented 7 years ago

Hi, I am working on formalizing the documentation of Vinyl so both the Typescript compiler and editors can better understand your API. There is currently an ongoing effort to add typings for the version 2.0.0.

We have two sources for this: the code and the official documentation.

Currently, we have an issue with the documented type of options.stat and the actual usage of it.

Here is the relevant comment by @felixfbecker:

  • if vinyl allows to pass just an object with isDirectory(), the typings should allow to pass just an object with isDirectory().
  • if vinyl requires a full-fledged Stat object, the tests should pass a full-fledged Stat object.

Could you clarify if the argument really has to be an instanceof fs.Stats or if an object with a subset of methods and attributes from is enough ? In the latter case, it would mean that user can create their own Stats-like objects and pass them as options (just as in your tests).

phated commented 7 years ago

instanceof is much too flaky to use in this library so there wouldn't be a consistent way to force a "full-fledged Stat object". I am fine with accepting Stats-like objects until we are able to address #105 in the future. Does that answer the question?

demurgos commented 7 years ago

Thank you, we'll make sure this is typed as such.