Комментарии:
Ok, but in what scenario getDeepValue is better than simple obj[key1][key2]? Or that was just an example, but then i would struggle to figure out a good case for what you showed today
ОтветитьGreat vids! I'm curious to see how you would approach this pattern to accept a dynamic number of keys.
Ответитьtype ExhaustiveKeyValueMap<
Key,
Value,
key extends Key,
unmappedKey extends Exclude<Key, key>,
value extends Value,
unmappedValue extends Exclude<Value, value>
> = {[k in unmappedKey]: unmappedValue}
- it should only really need to pass the first two generics
- DOES NOT NEED the mapping to be perfectly one to one, but more until either Key or Value runs out of unmappedKey or unmappedValue to supply.
ideas? 😢
Your short videos are so fun. I like how you show how easy is to accomplish tasks in typescript. Thank you.
ОтветитьI love British people
ОтветитьBro I love you
ОтветитьCan't wait for the course 🤩! Please take my money 🤑!
ОтветитьHow can use generics to get a instance of a class knowing all my params will be the same but the result will be a different class instance. In example func get(id,group) = ClassA | ClassB | ClassC
Is there a way to call the method. Get<ClassA>(1,'Friends') returns instance ClassA
The `extends` keyword is certainly useful but this is not a good case for it. In the typical use, the arguments to `getDeepValue()` would be unknown strings — obviously, if they were known, you could use ordinary dot-dereference — and the call would not compile.
ОтветитьHi. Could you please give me a hint? I'd like to make a function, accepting 2 optional arguments A and B. If argument A provided, request one more argument C. Is it doable with generics?
ОтветитьReally liked the TypeScript Videos
Ответитьwhy not using just the dot reference ?
Ответить