Skip to content

Commit d5b7199

Browse files
authored
chore: fix stackblitz output types (#6346)
1 parent bea006b commit d5b7199

4 files changed

Lines changed: 16 additions & 1 deletion

File tree

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
"dependencies": {
1414
"@trpc/client": "npm:@trpc/client@next",
1515
"@trpc/server": "npm:@trpc/server@next",
16+
"superjson": "^1.12.4",
1617
"zod": "^3.0.0"
1718
},
1819
"devDependencies": {

src/client/index.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import {
1111
* We only import the `AppRouter` type from the server - this is not available at runtime
1212
*/
1313
import type { AppRouter } from '../server/index.js';
14+
import { transformer } from '../shared/transformer.js';
1415

1516
// Initialize the tRPC client
1617
const trpc = createTRPCClient<AppRouter>({
@@ -19,9 +20,11 @@ const trpc = createTRPCClient<AppRouter>({
1920
condition: (op) => op.type === 'subscription',
2021
true: unstable_httpSubscriptionLink({
2122
url: 'http://localhost:3000',
23+
transformer,
2224
}),
2325
false: unstable_httpBatchStreamLink({
2426
url: 'http://localhost:3000',
27+
transformer,
2528
}),
2629
}),
2730
],

src/server/trpc.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
11
import { initTRPC } from '@trpc/server';
2+
import { transformer } from '../shared/transformer.js';
23

34
/**
45
* Initialization of tRPC backend
56
* Should be done only once per backend!
67
*/
7-
const t = initTRPC.create();
8+
const t = initTRPC.create({
9+
transformer,
10+
});
811

912
/**
1013
* Export reusable router and procedure helpers

src/shared/transformer.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
/**
2+
* If you need to add transformers for special data types like `Temporal.Instant` or `Temporal.Date`, `Decimal.js`, etc you can do so here.
3+
* Make sure to import this file rather than `superjson` directly.
4+
* @see https://github.com/blitz-js/superjson#recipes
5+
*/
6+
import superjson from 'superjson';
7+
8+
export const transformer = superjson;

0 commit comments

Comments
 (0)