-
Notifications
You must be signed in to change notification settings - Fork 45.6k
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
Add Node.js 12 support to react-fs #20541
Changes from 4 commits
138d9cb
847841d
9d5d328
9c70305
f49efc8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -70,50 +70,73 @@ declare module 'EventListener' { | |
declare function __webpack_chunk_load__(id: string): Promise<mixed>; | ||
declare function __webpack_require__(id: string): any; | ||
|
||
declare module 'fs/promises' { | ||
declare var access: (path: string, mode?: number) => Promise<void>; | ||
declare var lstat: ( | ||
path: string, | ||
options?: ?{bigint?: boolean}, | ||
) => Promise<mixed>; | ||
declare var readdir: ( | ||
path: string, | ||
declare module 'fs' { | ||
declare function existsSync(path: string): boolean; | ||
declare function readFileSync(path: string | Buffer | URL | number): Buffer; | ||
declare function readFileSync( | ||
path: string | Buffer | URL | number, | ||
encoding: string, | ||
): string; | ||
declare function readFileSync( | ||
path: string | Buffer | URL | number, | ||
options: {encoding: string, flag?: string}, | ||
): string; | ||
declare function readFileSync( | ||
path: string | Buffer | URL | number, | ||
options: {encoding?: void, flag?: string}, | ||
): Buffer; | ||
declare function writeFileSync( | ||
filename: string, | ||
data: Buffer | string, | ||
options?: | ||
| ?string | ||
| string | ||
| { | ||
encoding?: ?string, | ||
withFileTypes?: ?boolean, | ||
mode?: number, | ||
flag?: string, | ||
}, | ||
) => Promise<Buffer>; | ||
declare var readFile: ( | ||
path: string, | ||
options?: | ||
| ?string | ||
| { | ||
encoding?: ?string, | ||
}, | ||
) => Promise<Buffer>; | ||
declare var readlink: ( | ||
path: string, | ||
options?: | ||
| ?string | ||
| { | ||
encoding?: ?string, | ||
}, | ||
) => Promise<mixed>; | ||
declare var realpath: ( | ||
path: string, | ||
options?: | ||
| ?string | ||
| { | ||
encoding?: ?string, | ||
}, | ||
) => Promise<mixed>; | ||
declare var stat: ( | ||
path: string, | ||
options?: ?{bigint?: boolean}, | ||
) => Promise<mixed>; | ||
): void; | ||
declare class FSPromise { | ||
access(path: string, mode?: number): Promise<void>; | ||
lstat(path: string, options?: ?{bigint?: boolean}): Promise<mixed>; | ||
readdir( | ||
path: string, | ||
options?: | ||
| ?string | ||
| { | ||
encoding?: ?string, | ||
withFileTypes?: ?boolean, | ||
}, | ||
): Promise<Buffer>; | ||
readFile( | ||
path: string, | ||
options?: | ||
| ?string | ||
| { | ||
encoding?: ?string, | ||
}, | ||
): Promise<Buffer>; | ||
readlink( | ||
path: string, | ||
options?: | ||
| ?string | ||
| { | ||
encoding?: ?string, | ||
}, | ||
): Promise<mixed>; | ||
realpath( | ||
path: string, | ||
options?: | ||
| ?string | ||
| { | ||
encoding?: ?string, | ||
}, | ||
): Promise<mixed>; | ||
stat(path: string, options?: ?{bigint?: boolean}): Promise<mixed>; | ||
} | ||
declare var promises: FSPromise; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think you can put the type here inline without a class?
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This pattern was copied directly from the default type definitions There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
} | ||
|
||
declare module 'pg' { | ||
declare var Pool: ( | ||
options: mixed, | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Kind of unfortunate that we're not relying on built-in definitions here. Maybe we can just get rid of this when we update Flow and get Promises from upstream.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So there are built in definitions that could be used but there is no promises definition for fs.promises.lstat, fs.promises.stat does not define an option, and the default fs.promises.realpath is ambiguous.
If there is an easy way to overload specific entries with flow? I couldn't figure out how to do that, but if we could overload just those three functions we could avoid the rest of the noise