How to NoInfer (new TS 5.4 Feature)
Вставка
- Опубліковано 11 вер 2024
- TypeScript 5.4 has a new feature to give you more control over how type inference works. Let's check it out!
My Links
shaky.sh
shaky.sh/tools
#programming #coding #typescript #noinfer #typeinference
#frontenddeveloper #backenddeveloper #softwareengineer #softwareengineering #softwaredevelopment
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 UA-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 !👍
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]
: [];
}
I would follow this video with how to add the NoInfer type as an excluded, not recommended keyword in lint Sonar.
Great job dude ! 🎉
Need more content with TS
Great
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?
Very cool!
before NoInfer, must know when infer. When?
ohhh your fonts is so cool 🥺...what's?
Mono Lisa
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 :)