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: Serialize<Record<string, any>> gets inferred as {} #4985

Closed
1 task done
jussisaurio opened this issue Oct 31, 2023 · 0 comments · Fixed by #4986
Closed
1 task done

bug: Serialize<Record<string, any>> gets inferred as {} #4985

jussisaurio opened this issue Oct 31, 2023 · 0 comments · Fixed by #4986
Assignees
Labels
🐛 bug Something isn't working

Comments

@jussisaurio
Copy link
Contributor

jussisaurio commented Oct 31, 2023

Provide environment information

trpc commit 43e0da13073c8e5426c4c4fb6c3fb09e598fc6fe

Describe the bug

e.g. when using z.record(z.any()) as output validator, the inferred type on the client is {}.

Actual:

type Baz = Serialize<Record<string, any>>; // {}

Expected:

type Baz = Serialize<Record<string, any>>; // Record<string, any>, or { [x: string]: any; }

Link to reproduction

https://youtube.com

To reproduce

Paste the bug description into packages/server/src/shared/internal/serialize.ts

Additional information

Serialize<Record<symbol, string>> also gets inferred as { [x: symbol]: string } which is incorrect. Perhaps that would be a separate issue to file, but I think multiple of these bugs related to Serialize<Record<...>> can probably be fixed in one go.

👨‍👧‍👦 Contributing

  • 🙋‍♂️ Yes, I'd be down to file a PR fixing this bug!

Funding

  • You can sponsor this specific effort via a Polar.sh pledge below
  • We receive the pledge once the issue is completed & verified
Fund with Polar
@jussisaurio jussisaurio added 🐛 bug Something isn't working and removed 🐛 bug: unconfirmed labels Oct 31, 2023
@jussisaurio jussisaurio self-assigned this Oct 31, 2023
@KATT KATT closed this as completed in #4986 Nov 2, 2023
KATT added a commit that referenced this issue Nov 2, 2023
…procedure outputs (#4986)

* fix #4985: fix some issues with inferring Record types as procedure outputs

* reduce diff

* make `SerializeObjectKey`

---------

Co-authored-by: Alex / KATT <alexander@n1s.se>
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 16, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
🐛 bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant