-
Notifications
You must be signed in to change notification settings - Fork 23
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Bug] Inferred types break with certain target types #148
Comments
@C-Higgins Thanks for taking the time to report this! Sounds like a weird narrowing/widening issue with Typescript Union Type being processed recursively by: export type StrictSchema<Target = any, Source = any> = {
/** `destinationProperty` is the name of the property of the target object you want to produce */
[destinationProperty in keyof Target]:
| ActionString<Source>
| ActionFunction<Target, Source, Target[destinationProperty]>
| ActionAggregator<Source>
| ActionSelector<Source, Target>
| StrictSchema<Target[destinationProperty], Source>;
export interface ActionFunction<D = any, S = any, R = any> {
(iteratee: S, source: S[], target: D): R;
} Let me dig this a bit, and come back to you when I have a clue :) Edit: this is definitely a typescript widening behaviour replacing export type StrictSchema<Target = any, Source = any> = {
/** `destinationProperty` is the name of the property of the target object you want to produce */
[destinationProperty in keyof Target]:
| ActionFunction<Target, Source, Target[destinationProperty]>
.... by export type StrictSchema<Target = any, Source = any> = {
/** `destinationProperty` is the name of the property of the target object you want to produce */
[destinationProperty in keyof Target]:
| (iteratee: Source, source: Source[], target: Target[destinationProperty]) => Target[destinationProperty] solves the issue 🙃 |
@C-Higgins This issue should have been fixed in #149 which is version |
When the target type is certain combinations of union types, I think when the unions share a property, the type of the ActionFunction breaks and no longer knows the types of the parameters.
** Reproduce **
As you can see,
it
should be of type{c:string}
, for the first property, but it is not. The other parameters are also any. If you removea
from the second type, it works as expected.The text was updated successfully, but these errors were encountered: