In SIX LINES of Code I Fixed Two Major NodeJS TypeScript Issues

preview_player
Показать описание

The promisify utility in node has two major flaws in its type definitions. So let's fix them in six lines of code.

0:00 Intro
0:11 The issue
3:50 The solution
8:40 Try the solution
10:30 Outro
Рекомендации по теме
Комментарии
Автор

Builtin implementation was probably created before TS features making this possible existed. Cool video. Very fun to watch after dealing with C++ compile-time magic

alexeydmitrievich
Автор

This built in implementation reminds me of the package that checks for odd/even with millions of if checks 😂

royz_
Автор

Mate, I’m learning so much from watching you work with types! Thank you!

ryanvarley
Автор

We need this in the @types/node package now!

caineandrebekah
Автор

These are the kinds of things for which I'm paying my internet bills.

supravatsamanta
Автор

Man, you're miles away from every other Typescript youtuber I see.
Great content, actual useful code, and great explanation. Nailed it!

leogt
Автор

I always learn something useful.... mostly how damn smart you are!

RobertMacLeanDeveloper
Автор

Have you tried the twoslash extension to have more persistently visible type information?

AlexanderBrownDrJKL
Автор

Could you to the same to the pipe function from lodash? I’ve tried many times to tackle that but with no success. I’d love to see how it’s done.

feldinho
Автор

I throw the argument out that if you have 6+ parameters then refactor. Is there a way to do this while still keeping just five or fewer?

deathone
Автор

Watching this I have learned 2 things:
- I know nothing.
- The people creating nodeJS are the same as me.

axeloord
Автор

I think GetResult and Callback not needed:

type Promisified<Fn extends Function> = Fn extends (
...args: [...infer Args, ((err?: any) => void) | ((err: any, result?: infer R) => void)]
) => void
? (...args: Args) => Promise<unknown extends R ? void : R>
: never;

BeyuuKT
Автор

Can you do a video on creating types for pipe function?

ayushtripathi
Автор

Love this!

I wonder what the performance cost is of your approach compared to the size cost of Node’s explicit approach. 🤔

ErrorNaN_
Автор

I think you mean major instead of mayor

amirulidzham
Автор

All that remains is to add support for overloaded functions (it is not really that easy)

vanilla_master
Автор

interesting, can we use it with overloading, for example for autocarry functions :) when u have sum = (x, y, z) => x + y + z and u can call it like sum(5) -> (y, z) or sum(1, 2, 3) -> 6

snatvb
Автор

Bro is on the way of creating sane STD for Node 💀

winchester
Автор

NodeJS: what are you doing, you make it more complex with some overhead, it just works, why do you need the types, just read the docs and run it. 😉

PieterWigboldus
Автор

Man the NodeJS implementation is so goofy

LePhenixGD