-
Notifications
You must be signed in to change notification settings - Fork 30.5k
[types/node] Add promisify to util [wip] #16946
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
Conversation
A simple type definition that allows us to use the exciting util.promisify function.
|
types/node/index.d.ts to authors (@DefinitelyTyped/DefinitelyTyped @parambirs @robdesideri @tellnes Microsoft TypeScript (account can't be detected)). Could you review this PR? Checklist
|
|
There is issue for this PR #16860 |
|
It looks correct to me, but it would be great if it somehow preserved the type information from the second argument of the callback by default. Also, it is missing |
👍 |
|
I will merge the PR and open a separate issue regarding missing |
|
this wild have a look at @types/bluebird promisify type definition, it's such better DefinitelyTyped/types/bluebird/index.d.ts Lines 625 to 638 in 4daa341
|
|
Why this function was added to type definition for nodejs v7? util.promisify is available since v8. |
|
@ikokostya What? |
|
Current index.d.ts contains type definitions for Node.js v7
But util.promisify was added in Node.js v8 and is not available in Node.js 7 |
|
I think need to move current |
|
You should use something more like https://github.com/types/npm-thenify/blob/6ec63ea2de3f0e09d40dfccc9861f3aaa90b8853/index.d.ts#L19-L23 to keep the types. However, support for multiple arguments and the |
|
We should probably revert this as |
|
@blakeembrey I think you're right, but that solution still limits the number of arguments the function can accept. I don't think |
|
@cjhowe7 You can overload it up to 10, and then just do Edit: To clarify, typing it 100% perfectly is impossible. But we can get as close as possible by capturing the information that is available. Especially with default generics, we can do |
[types/node] Add promisify to util [wip]


A simple type definition that allows us to use the exciting util.promisify function.
Please fill in this template.
npm run lint package-name(ortscif notslint.jsonis present).Select one of these and delete the others:
If changing an existing definition:
tslint.jsoncontaining{ "extends": "dtslint/dt.json" }.I've never contributed before, and I'm new to Typescript, so please bear with me. Thanks!