great video as always! glad to see some coverage on this. great example too! i wish they'd have other syntax for this. something like `const config: Satisfies` or `const config: satisfies Config` just so the important bit isn't all the way at the end.
Jesus christ I was lacking this feature for years. Its very helpful when using with typeof of this config. There was no way to create safely typed object without ruining inference to some very broad useless type. Great explanation for someone without clue of this problem
Nice! You thought of a good example instead of copying the "satisfies User" one, seen in like every other RUclips video on this topic. Nice explanation as well!
I guess I'm a little puzzled with whether or not you could then change tryReconnect in const config to a regular boolean and if it would show a type error within the start function's createConnection call since it's trying to call tryReconnect, which is now just a regular boolean. I guess this is mostly for when the data isn't expected to change, so you can write start() assuming config is a specific shape of Config (with `${port}`, and tryReconnect()).
Kinda! I think of extends a little differently, since in a generic like ‘T extends User’, we know nothing about T except what we know about User, so we can only treat T as a User. Satisfies is the reverse, where the initial type is narrower than the type it satisfies.
You explain it better than the docs 😂
great video as always! glad to see some coverage on this. great example too! i wish they'd have other syntax for this. something like `const config: Satisfies` or `const config: satisfies Config` just so the important bit isn't all the way at the end.
Imho the best explanation of satisfies that I watched/read so far. A real life example is what is needed to best explain when to use it
Jesus christ I was lacking this feature for years. Its very helpful when using with typeof of this config. There was no way to create safely typed object without ruining inference to some very broad useless type. Great explanation for someone without clue of this problem
Such precise and helpful explanation. You are my go-to-guy for typescript.
A great explanation of Satisfies. I can't say whether it's the best I've seen as I was 80% of the way there but it's up at the top.
OMG i love this channel
Very nice example!
Excellent explanation! Great job. I was so impressed I subscribed :)
Fantastic example! … but at the end 5:32, what if you changed the tryReconnect on line 22 to a boolean… wouldn’t line 28 cause an error?
amazing explanation thank you
awesome. love these vids. Not a second wasted.
Nice! You thought of a good example instead of copying the "satisfies User" one, seen in like every other RUclips video on this topic. Nice explanation as well!
Nice vid, thank you!
What is the benefit of using `satisfies` instead of just typing it to the `Config` object?
I guess I'm a little puzzled with whether or not you could then change tryReconnect in const config to a regular boolean and if it would show a type error within the start function's createConnection call since it's trying to call tryReconnect, which is now just a regular boolean.
I guess this is mostly for when the data isn't expected to change, so you can write start() assuming config is a specific shape of Config (with `${port}`, and tryReconnect()).
Satisfies has the same semantics as extends for generics right? Satisfies is basically just top level generics.
Kinda! I think of extends a little differently, since in a generic like ‘T extends User’, we know nothing about T except what we know about User, so we can only treat T as a User. Satisfies is the reverse, where the initial type is narrower than the type it satisfies.
@@andrew-burgess Oh yeah, you're right. There is significant overlap, but extends would accept extra props where as satisfies would not.
Is there any reason not to use "satisfies" now?
the docs are using a stupid example, your code are far more clear with actually more examples in it
👎👎