I remember when you started your typescript structural metaprogramming journey. You’ve come far mate. Though I’d probably want a tuple return to maintain order and not have an array with multiple elements of the same string value. export namespace Union { export type ToIntersection = ( U extends never ? never : (arg: U) => never ) extends (arg: infer I) => void ? I : never; export type ToTuple = Union.ToIntersection< T extends never ? never : (t: T) => T > extends (_: never) => infer W ? [...Union.ToTuple, W] : []; }
That createMenu function makes absolutely no sense, code wise. It doesn't even create a menu. Why would you ever want to construct anything like that, that way? Examples work best with real-life bits of code. This is just confusing because I'm constantly wondering "who would ever write bad code like this?" even if it kinda explains the NoInfer thing :)
BTW, here's the code from the last (best, imho) example in the video! Thanks for watching! shaky.sh/pastes/typescript-noinfer/
Best NoInfer explanation on TH-cam to date!! Love all your videos, Andrew! Keep 'em coming...
What a GREAT lesson. I definitely faced those problems before at work, I'll probably sent it to others tomorrow
Best TS channel ever❤
Very nicely explained !👍
Very well explained.
This video is great! So glad to have this feature in TS now 🔥
I remember when you started your typescript structural metaprogramming journey. You’ve come far mate. Though I’d probably want a tuple return to maintain order and not have an array with multiple elements of the same string value.
export namespace Union {
export type ToIntersection = (
U extends never ? never : (arg: U) => never
) extends (arg: infer I) => void
? I
: never;
export type ToTuple = Union.ToIntersection<
T extends never ? never : (t: T) => T
> extends (_: never) => infer W
? [...Union.ToTuple, W]
: [];
}
Great job dude ! 🎉
Need more content with TS
I would follow this video with how to add the NoInfer type as an excluded, not recommended keyword in lint Sonar.
Great
Very cool!
Side note: ma man looks good with the beard.
2:00 ... What if you NoInfer both a and b? What does the linter say then?
ohhh your fonts is so cool 🥺...what's?
Mono Lisa
before NoInfer, must know when infer. When?
Shouldn't this be the default?
That createMenu function makes absolutely no sense, code wise. It doesn't even create a menu. Why would you ever want to construct anything like that, that way?
Examples work best with real-life bits of code. This is just confusing because I'm constantly wondering "who would ever write bad code like this?" even if it kinda explains the NoInfer thing :)