this is an old solution. It worked with 2.4/ES6, for example, but type constraints are now way tighter and it doesn't work anymore with 4.2, yes.
I think solutions to this example should try to make use of TS typecheck at compile time to get the intersecting types.
Like I tried here: https://www.codewars.com/kata/reviews/5916d24f81639e467a0009d8/groups/5e233520aa63470001e3ed38 I don't know if there is an Utility Type for that: R extends { [K in keyof U]: K extends keyof T ? U[K] : never }? Anyways it was fun trying to make it myself
R extends { [K in keyof U]: K extends keyof T ? U[K] : never }
This comment is hidden because it contains spoiler information about the solution
I'm not sure if the types of properties are rightly infered if you don't define them in Animal::constructor. At least my limited testing suggest it doesn't (they are all any).
any
So you lose all typescript goodness with the parameters.
Loading collection data...
this is an old solution. It worked with 2.4/ES6, for example, but type constraints are now way tighter and it doesn't work anymore with 4.2, yes.
I think solutions to this example should try to make use of TS typecheck at compile time to get the intersecting types.
Like I tried here: https://www.codewars.com/kata/reviews/5916d24f81639e467a0009d8/groups/5e233520aa63470001e3ed38
I don't know if there is an Utility Type for that:
R extends { [K in keyof U]: K extends keyof T ? U[K] : never }
?Anyways it was fun trying to make it myself
This comment is hidden because it contains spoiler information about the solution
I'm not sure if the types of properties are rightly infered if you don't define them in Animal::constructor. At least my limited testing suggest it doesn't (they are all
any
).So you lose all typescript goodness with the parameters.