@types/node - util.promisify unable to handle functions with optional arguments #53785
Unanswered
MKuranowski
asked this question in
Issues with a @types package
Replies: 1 comment
-
As for the solution. TypeScript explicitly mentions that more specific overloads should be placed before generic ones. This would suggest that the order of declarations at https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/node/util.d.ts#L98 should be swapped around. I tried this, and, this works for this case; however this also breaks a ton of other tests. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I was advised to re-open issue #20497 as a discussion.
Generally speaking, when trying to promisify a function with an optional argument the most-restrictive overload (without any optional arguments) is inferred.
It's not uncommon to see such methods, for example in Node's standard library: zlib.deflate or fs.read.
The simplest test case I was able to think of looks like this:
Beta Was this translation helpful? Give feedback.
All reactions