Skip to content

Commit

Permalink
Support method unbound for fs/promises in flow 0.154
Browse files Browse the repository at this point in the history
Summary:
<!--
  If this is a change to library defintions, please include links to relevant documentation.
  If this is a documentation change, please prefix the title with [DOCS].

  If this is neither, ensure you opened a discussion issue and link it in the PR description.
-->
This PR allows using fs/promises like this in flow 0.154:
```js
const {writeFile} = require('fs').promises;
```

Node fs/promises doc: https://nodejs.org/api/fs.html#fs_promises_api

Pull Request resolved: #8697

Reviewed By: dsainati1

Differential Revision: D29451697

Pulled By: gkz

fbshipit-source-id: 3f0638503681c1f69f82db17a1ac661a55f30405
  • Loading branch information
atabel authored and facebook-github-bot committed Jun 30, 2021
1 parent 5c64990 commit 189aa87
Show file tree
Hide file tree
Showing 2 changed files with 260 additions and 256 deletions.
18 changes: 11 additions & 7 deletions lib/node.js
Original file line number Diff line number Diff line change
Expand Up @@ -1321,7 +1321,7 @@ declare module "fs" {
}

declare type FSPromisePath = string | Buffer | URL;
declare class FSPromise {
declare type FSPromise = {
access(path: FSPromisePath, mode?: number): Promise<void>,
appendFile(path: FSPromisePath | FileHandle, data: string | Buffer, options: WriteOptions | string): Promise<void>,
chmod(path: FSPromisePath, mode: number): Promise<void>,
Expand Down Expand Up @@ -1356,12 +1356,15 @@ declare module "fs" {
...
}>,
readdir(path: FSPromisePath, options?: string | EncodingOptions): Promise<string[]>,
readFile(path: FSPromisePath | FileHandle, options: string): Promise<string>,
readFile(path: FSPromisePath | FileHandle, options?: EncodingFlag): Promise<Buffer>,
readlink(path: FSPromisePath, options: BufferEncoding): Promise<Buffer>,
readlink(path: FSPromisePath, options?: string | EncodingOptions): Promise<string>,
realpath(path: FSPromisePath, options: BufferEncoding): Promise<Buffer>,
realpath(path: FSPromisePath, options?: string | EncodingOptions): Promise<string>,
readFile:
& ((path: FSPromisePath | FileHandle, options: string) => Promise<string>)
& ((path: FSPromisePath | FileHandle, options?: EncodingFlag) => Promise<Buffer>),
readlink:
& ((path: FSPromisePath, options: BufferEncoding) => Promise<Buffer>)
& ((path: FSPromisePath, options?: string | EncodingOptions) => Promise<string>),
realpath:
& ((path: FSPromisePath, options: BufferEncoding) => Promise<Buffer>)
& ((path: FSPromisePath, options?: string | EncodingOptions) => Promise<string>),
rename(oldPath: FSPromisePath, newPath: FSPromisePath): Promise<void>,
rmdir(path: FSPromisePath): Promise<void>,
stat(path: FSPromisePath): Promise<Stats>,
Expand All @@ -1385,6 +1388,7 @@ declare module "fs" {
data: string | Buffer | Uint8Array,
options?: string | WriteOptions
): Promise<void>,
...
}

declare var promises: FSPromise;
Expand Down
Loading

0 comments on commit 189aa87

Please sign in to comment.