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

fix(client+server): non-records inferred as records when serializing as json #5077

Merged
merged 2 commits into from Nov 21, 2023

Conversation

jussisaurio
Copy link
Contributor

Closes #5075

🎯 Changes

πŸ’€

βœ… Checklist

  • I have followed the steps listed in the Contributing guide.
  • If necessary, I have added documentation related to the changes made.
  • I have added or updated the tests related to the changes made.

@jussisaurio jussisaurio requested a review from a team as a code owner November 21, 2023 14:39
Copy link

vercel bot commented Nov 21, 2023

The latest updates on your projects. Learn more about Vercel for Git β†—οΈŽ

Name Status Preview Comments Updated (UTC)
next-prisma-starter βœ… Ready (Inspect) Visit Preview πŸ’¬ Add feedback Nov 21, 2023 3:21pm
og-image βœ… Ready (Inspect) Visit Preview πŸ’¬ Add feedback Nov 21, 2023 3:21pm
trpc-next-app-dir βœ… Ready (Inspect) Visit Preview πŸ’¬ Add feedback Nov 21, 2023 3:21pm
1 Ignored Deployment
Name Status Preview Comments Updated (UTC)
www ⬜️ Ignored (Inspect) Visit Preview Nov 21, 2023 3:21pm

@jussisaurio
Copy link
Contributor Author

Should we have some sort of kitchen sink test somewhere that tests a huge vomitous mass of different inference scenarios? Kind of unfortunate how much we are breaking userland rn with these :(

This current issue is part of a chain reaction from #4985

@@ -18,6 +18,8 @@ type IsAny<T> = 0 extends T & 1 ? true : false;
// support it as both a Primitive and a NonJsonPrimitive
type JsonReturnable = JsonPrimitive | undefined;

type IsRecord<T> = keyof WithoutIndexSignature<T> extends never ? true : false;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll change this to have an object check as well. Even though no tests fail, this is still too broad

@KATT KATT changed the title fix(client+server): non-records inferred as records fix(client+server): non-records inferred as records when serializing as json Nov 21, 2023
Comment on lines +48 to +75
zArray: z.array(z.string()),
zRecord: z.record(z.string()),
zTuple: z.tuple([z.string(), z.number()]),
zUnion: z.union([z.string(), z.number()]),
zIntersection: z.intersection(
z.object({ name: z.string() }),
z.object({ age: z.number() }),
),
zLazy: z.lazy(() => z.string()),
zPromise: z.promise(z.string()),
zFunction: z.function(),
zMap: z.map(z.string(), z.number()),
zSet: z.set(z.string()),
zEnum: z.enum(['foo', 'bar']),
zNativeEnum: z.nativeEnum({ foo: 1, bar: 2 }),
zUnknown: z.unknown(),
zNullable: z.nullable(z.string()),
zOptional: z.optional(z.string()),
zLiteral: z.literal('foo'),
zBoolean: z.boolean(),
zString: z.string(),
zNumber: z.number(),
zBigint: z.bigint(),
zDate: z.date(),
zUndefined: z.undefined(),
zAny: z.any(),
zArrayOptional: z.array(z.string()).optional(),
zArrayOrRecord: z.union([z.array(z.string()), z.record(z.string())]),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

woah that's extensive

@KATT KATT merged commit 6af030a into main Nov 21, 2023
37 of 38 checks passed
@KATT KATT deleted the fix-5075 branch November 21, 2023 17:09
@jussisaurio
Copy link
Contributor Author

@KATT I was just about to change the IsRecord type to be a bit more restrictive... I'm sure having it like that will again break something πŸ˜‚ πŸ˜‚

renovate bot added a commit to ettorepuccetti/terrarossa that referenced this pull request Nov 21, 2023
[![Mend Renovate logo
banner](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com)

This PR contains the following updates:

| Package | Change | Age | Adoption | Passing | Confidence |
|---|---|---|---|---|---|
| [@trpc/client](https://trpc.io)
([source](https://togithub.com/trpc/trpc)) | [`10.43.7` ->
`10.44.0`](https://renovatebot.com/diffs/npm/@trpc%2fclient/10.43.7/10.44.0)
|
[![age](https://developer.mend.io/api/mc/badges/age/npm/@trpc%2fclient/10.44.0?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![adoption](https://developer.mend.io/api/mc/badges/adoption/npm/@trpc%2fclient/10.44.0?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![passing](https://developer.mend.io/api/mc/badges/compatibility/npm/@trpc%2fclient/10.43.7/10.44.0?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![confidence](https://developer.mend.io/api/mc/badges/confidence/npm/@trpc%2fclient/10.43.7/10.44.0?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
| [@trpc/next](https://trpc.io)
([source](https://togithub.com/trpc/trpc)) | [`10.43.7` ->
`10.44.0`](https://renovatebot.com/diffs/npm/@trpc%2fnext/10.43.7/10.44.0)
|
[![age](https://developer.mend.io/api/mc/badges/age/npm/@trpc%2fnext/10.44.0?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![adoption](https://developer.mend.io/api/mc/badges/adoption/npm/@trpc%2fnext/10.44.0?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![passing](https://developer.mend.io/api/mc/badges/compatibility/npm/@trpc%2fnext/10.43.7/10.44.0?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![confidence](https://developer.mend.io/api/mc/badges/confidence/npm/@trpc%2fnext/10.43.7/10.44.0?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
| [@trpc/react-query](https://trpc.io)
([source](https://togithub.com/trpc/trpc)) | [`10.43.7` ->
`10.44.0`](https://renovatebot.com/diffs/npm/@trpc%2freact-query/10.43.7/10.44.0)
|
[![age](https://developer.mend.io/api/mc/badges/age/npm/@trpc%2freact-query/10.44.0?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![adoption](https://developer.mend.io/api/mc/badges/adoption/npm/@trpc%2freact-query/10.44.0?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![passing](https://developer.mend.io/api/mc/badges/compatibility/npm/@trpc%2freact-query/10.43.7/10.44.0?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![confidence](https://developer.mend.io/api/mc/badges/confidence/npm/@trpc%2freact-query/10.43.7/10.44.0?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
| [@trpc/server](https://trpc.io)
([source](https://togithub.com/trpc/trpc)) | [`10.43.7` ->
`10.44.0`](https://renovatebot.com/diffs/npm/@trpc%2fserver/10.43.7/10.44.0)
|
[![age](https://developer.mend.io/api/mc/badges/age/npm/@trpc%2fserver/10.44.0?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![adoption](https://developer.mend.io/api/mc/badges/adoption/npm/@trpc%2fserver/10.44.0?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![passing](https://developer.mend.io/api/mc/badges/compatibility/npm/@trpc%2fserver/10.43.7/10.44.0?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![confidence](https://developer.mend.io/api/mc/badges/confidence/npm/@trpc%2fserver/10.43.7/10.44.0?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|

---

### Release Notes

<details>
<summary>trpc/trpc (@&#8203;trpc/client)</summary>

### [`v10.44.0`](https://togithub.com/trpc/trpc/releases/tag/v10.44.0)

[Compare
Source](https://togithub.com/trpc/trpc/compare/v10.43.7...v10.44.0)

#### What's Changed

- fix(client+server): non-records inferred as records when serializing
as json by [@&#8203;jussisaurio](https://togithub.com/jussisaurio) in
[trpc/trpc#5077
- fix(server): Response meta headers type by
[@&#8203;AlexXanderGrib](https://togithub.com/AlexXanderGrib) in
[trpc/trpc#5074
- feat(react): allow conditional ssr based on context by
[@&#8203;jonluca](https://togithub.com/jonluca) in
[trpc/trpc#4997
- fix(server): constrain the IsRecord utility type to objects by
[@&#8203;jussisaurio](https://togithub.com/jussisaurio) in
[trpc/trpc#5081

#### New Contributors

- [@&#8203;jonluca](https://togithub.com/jonluca) made their first
contribution in
[trpc/trpc#4997

**Full Changelog**:
trpc/trpc@v10.43.7...v10.44.0

</details>

---

### Configuration

πŸ“… **Schedule**: Branch creation - "after 3am,before 9am" (UTC),
Automerge - "after 3am,before 9am" (UTC).

🚦 **Automerge**: Enabled.

β™» **Rebasing**: Whenever PR becomes conflicted, or you tick the
rebase/retry checkbox.

πŸ”• **Ignore**: Close this PR and you won't be reminded about these
updates again.

---

- [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check
this box

---

This PR has been generated by [Mend
Renovate](https://www.mend.io/free-developer-tools/renovate/). View
repository job log
[here](https://developer.mend.io/github/ettorepuccetti/terrarossa).

<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNy41OS44IiwidXBkYXRlZEluVmVyIjoiMzcuNTkuOCIsInRhcmdldEJyYW5jaCI6Im1haW4ifQ==-->

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
kodiakhq bot added a commit to weareinreach/TransMascFutures that referenced this pull request Nov 22, 2023
[![Mend Renovate logo banner](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com)

This PR contains the following updates:

| Package | Change | Age | Adoption | Passing | Confidence |
|---|---|---|---|---|---|
| [@tabler/icons-react](https://tabler-icons.io) ([source](https://togithub.com/tabler/tabler-icons)) | [`2.41.0` -> `2.42.0`](https://renovatebot.com/diffs/npm/@tabler%2ficons-react/2.41.0/2.42.0) | [![age](https://developer.mend.io/api/mc/badges/age/npm/@tabler%2ficons-react/2.42.0?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://developer.mend.io/api/mc/badges/adoption/npm/@tabler%2ficons-react/2.42.0?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://developer.mend.io/api/mc/badges/compatibility/npm/@tabler%2ficons-react/2.41.0/2.42.0?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://developer.mend.io/api/mc/badges/confidence/npm/@tabler%2ficons-react/2.41.0/2.42.0?slim=true)](https://docs.renovatebot.com/merge-confidence/) |
| [@trpc/client](https://trpc.io) ([source](https://togithub.com/trpc/trpc)) | [`10.43.7` -> `10.44.0`](https://renovatebot.com/diffs/npm/@trpc%2fclient/10.43.7/10.44.0) | [![age](https://developer.mend.io/api/mc/badges/age/npm/@trpc%2fclient/10.44.0?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://developer.mend.io/api/mc/badges/adoption/npm/@trpc%2fclient/10.44.0?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://developer.mend.io/api/mc/badges/compatibility/npm/@trpc%2fclient/10.43.7/10.44.0?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://developer.mend.io/api/mc/badges/confidence/npm/@trpc%2fclient/10.43.7/10.44.0?slim=true)](https://docs.renovatebot.com/merge-confidence/) |
| [@trpc/next](https://trpc.io) ([source](https://togithub.com/trpc/trpc)) | [`10.43.7` -> `10.44.0`](https://renovatebot.com/diffs/npm/@trpc%2fnext/10.43.7/10.44.0) | [![age](https://developer.mend.io/api/mc/badges/age/npm/@trpc%2fnext/10.44.0?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://developer.mend.io/api/mc/badges/adoption/npm/@trpc%2fnext/10.44.0?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://developer.mend.io/api/mc/badges/compatibility/npm/@trpc%2fnext/10.43.7/10.44.0?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://developer.mend.io/api/mc/badges/confidence/npm/@trpc%2fnext/10.43.7/10.44.0?slim=true)](https://docs.renovatebot.com/merge-confidence/) |
| [@trpc/react-query](https://trpc.io) ([source](https://togithub.com/trpc/trpc)) | [`10.43.7` -> `10.44.0`](https://renovatebot.com/diffs/npm/@trpc%2freact-query/10.43.7/10.44.0) | [![age](https://developer.mend.io/api/mc/badges/age/npm/@trpc%2freact-query/10.44.0?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://developer.mend.io/api/mc/badges/adoption/npm/@trpc%2freact-query/10.44.0?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://developer.mend.io/api/mc/badges/compatibility/npm/@trpc%2freact-query/10.43.7/10.44.0?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://developer.mend.io/api/mc/badges/confidence/npm/@trpc%2freact-query/10.43.7/10.44.0?slim=true)](https://docs.renovatebot.com/merge-confidence/) |
| [@trpc/server](https://trpc.io) ([source](https://togithub.com/trpc/trpc)) | [`10.43.7` -> `10.44.0`](https://renovatebot.com/diffs/npm/@trpc%2fserver/10.43.7/10.44.0) | [![age](https://developer.mend.io/api/mc/badges/age/npm/@trpc%2fserver/10.44.0?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://developer.mend.io/api/mc/badges/adoption/npm/@trpc%2fserver/10.44.0?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://developer.mend.io/api/mc/badges/compatibility/npm/@trpc%2fserver/10.43.7/10.44.0?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://developer.mend.io/api/mc/badges/confidence/npm/@trpc%2fserver/10.43.7/10.44.0?slim=true)](https://docs.renovatebot.com/merge-confidence/) |
| [@types/react-dom](https://togithub.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/react-dom) ([source](https://togithub.com/DefinitelyTyped/DefinitelyTyped)) | [`18.2.16` -> `18.2.17`](https://renovatebot.com/diffs/npm/@types%2freact-dom/18.2.16/18.2.17) | [![age](https://developer.mend.io/api/mc/badges/age/npm/@types%2freact-dom/18.2.17?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://developer.mend.io/api/mc/badges/adoption/npm/@types%2freact-dom/18.2.17?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://developer.mend.io/api/mc/badges/compatibility/npm/@types%2freact-dom/18.2.16/18.2.17?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://developer.mend.io/api/mc/badges/confidence/npm/@types%2freact-dom/18.2.16/18.2.17?slim=true)](https://docs.renovatebot.com/merge-confidence/) |

---

### Release Notes

<details>
<summary>tabler/tabler-icons (@&#8203;tabler/icons-react)</summary>

### [`v2.42.0`](https://togithub.com/tabler/tabler-icons/releases/tag/v2.42.0): Release 2.42.0

[Compare Source](https://togithub.com/tabler/tabler-icons/compare/v2.41.0...v2.42.0)

<img src="https://github.com/tabler/tabler-icons/assets/1282324/00856af9-841d-4aa9-995d-121c7ddcc005" width="584" alt="" />

##### 18 new icons:

-   `calendar-dot`
-   `copy-check`
-   `copy-minus`
-   `copy-plus`
-   `copy-x`
-   `folder-root`
-   `gymnastics`
-   `layout-bottombar-inactive`
-   `layout-navbar-inactive`
-   `layout-sidebar-inactive`
-   `layout-sidebar-right-inactive`
-   `library-minus`
-   `library-photo`
-   `library-plus`
-   `library`
-   `message-reply`
-   `scuba-diving`
-   `snowboarding`

Fixed icons: `copy`, `message-chatbot`, `message-forward`, `message-report`

</details>

<details>
<summary>trpc/trpc (@&#8203;trpc/client)</summary>

### [`v10.44.0`](https://togithub.com/trpc/trpc/releases/tag/v10.44.0)

[Compare Source](https://togithub.com/trpc/trpc/compare/v10.43.7...v10.44.0)

#### What's Changed

-   fix(client+server): non-records inferred as records when serializing as json by [@&#8203;jussisaurio](https://togithub.com/jussisaurio) in [trpc/trpc#5077
-   fix(server): Response meta headers type by [@&#8203;AlexXanderGrib](https://togithub.com/AlexXanderGrib) in [trpc/trpc#5074
-   feat(react): allow conditional ssr based on context by [@&#8203;jonluca](https://togithub.com/jonluca) in [trpc/trpc#4997
-   fix(server): constrain the IsRecord utility type to objects by [@&#8203;jussisaurio](https://togithub.com/jussisaurio) in [trpc/trpc#5081

#### New Contributors

-   [@&#8203;jonluca](https://togithub.com/jonluca) made their first contribution in [trpc/trpc#4997

**Full Changelog**: trpc/trpc@v10.43.7...v10.44.0

</details>

---

### Configuration

πŸ“… **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).

🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied.

β™» **Rebasing**: Whenever PR is behind base branch, or you tick the rebase/retry checkbox.

πŸ‘» **Immortal**: This PR will be recreated if closed unmerged. Get [config help](https://togithub.com/renovatebot/renovate/discussions) if that's undesired.

---

 - [ ] If you want to rebase/retry this PR, check this box

---

This PR has been generated by [Mend Renovate](https://www.mend.io/free-developer-tools/renovate/). View repository job log [here](https://developer.mend.io/github/weareinreach/GLAAD).



PR-URL: #258
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Dec 21, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
2 participants