Skip to content
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: TypeError on SortBuildInput #54

Closed
Xavier-IV opened this issue Oct 10, 2022 · 4 comments · Fixed by #55
Closed

Bug: TypeError on SortBuildInput #54

Xavier-IV opened this issue Oct 10, 2022 · 4 comments · Fixed by #55

Comments

@Xavier-IV
Copy link
Contributor

Receiving this error while using this package as a dependent to typeorm-extension package.

Type 'Flatten<T[K]>' does not satisfy the constraint 'Record<string, any>'.
  Type 'unknown' is not assignable to type 'Record<string, any>'.

9     [K in keyof T]?: T[K] extends OnlyScalar<T[K]> ? `${SortDirection}` : T[K] extends Date ? `${SortDirection}` : T[K] extends OnlyObject<T[K]> ? SortBuildInput<Flatten<T[K]>> | SortWithOperator<Flatten<T[K]>> : never;

Versions

  • Node: 14.8.2
  • OS: MacOS Monterey, i7
  • TSC: 4.5.5

Reproduction

Additional Details

Upon compiling our application using tsc, we are thrown with the error stated above.

Steps to reproduce

What is Expected?

Error should not be thrown on typescript compilation.

What is actually happening?

We might have a solution for this. Changing this line seems to resolve the issue:

export type SortBuildInput<T> = {

Suggested Change:

export declare type SortBuildInput<T extends Record<string, any>> = {
    [K in keyof T]?: T[K] extends OnlyScalar<T[K]> ? `${SortDirection}` : T[K] extends Date ? `${SortDirection}` : T[K] extends OnlyObject<T[K]> ? SortBuildInput<Flatten<T[K]>> | SortWithOperator<Flatten<T[K]>> : never;
} | SortWithOperator<T>;

extending T with Record<string, any> does resolve it, but I am unsure if this was the initial author intention.

@Xavier-IV Xavier-IV changed the title Bug: TypeError Bug: TypeError on SortBuildInput Oct 10, 2022
@tada5hi
Copy link
Owner

tada5hi commented Oct 10, 2022

good catch 💪, thank you very much 👍

tada5hi added a commit that referenced this issue Oct 10, 2022
#54 TypeError on SortBuildInput
@Xavier-IV
Copy link
Contributor Author

Xavier-IV commented Oct 10, 2022

Thanks!

Might want to bump the npm version as well to include the smallfix, I'm not sure if that's something can be done via github

ps: typeorm-extension might want to bump dependencies version of this package too

@tada5hi
Copy link
Owner

tada5hi commented Oct 10, 2022

bumped the version of both packages ✌️
I hope that everything is now wokring for you 😊 .
If you have any other ideas or suggestions for improvement, I would be happy to receive further contributions.

Ps: Would be great if you would follow the guideline for conventional commits in the future.

@Xavier-IV
Copy link
Contributor Author

bumped the version of both packages ✌️ I hope that everything is now wokring for you 😊 . If you have any other ideas or suggestions for improvement, I would be happy to receive further contributions.

Ps: Would be great if you would follow the guideline for conventional commits in the future.

Thanks! Yes, appreciate you sharing the guideline.

Will be helpful in future contributions. Awesome works!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants