Evan
Evan3mo ago

TSC errors after upgrading to v11

Hello, I am trying to upgrade to v11 and encountering the following error:
tsc --declaration --emitDeclarationOnly


added 249 packages, and audited 523 packages in 3s

40 packages are looking for funding
run `npm fund` for details

found 0 vulnerabilities
node_modules/@trpc/server/dist/unstable-core-do-not-import/stream/jsonl.d.ts:6:22 - error TS2304: Cannot find name 'ReadableStreamDefaultReader'.

6 getReader: () => ReadableStreamDefaultReader<Uint8Array>;
~~~~~~~~~~~~~~~~~~~~~~~~~~~

node_modules/@trpc/server/dist/unstable-core-do-not-import/stream/jsonl.d.ts:82:69 - error TS2315: Type 'ReadableStream' is not generic.

82 export declare function jsonlStreamProducer(opts: ProducerOptions): ReadableStream<Uint8Array>;
~~~~~~~~~~~~~~~~~~~~~~~~~~

node_modules/@trpc/server/dist/unstable-core-do-not-import/stream/jsonl.d.ts:103:21 - error TS2304: Cannot find name 'ReadableStreamDefaultController'.

103 controller: ReadableStreamDefaultController<ChunkData | StreamInterruptedError>;
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

node_modules/@trpc/server/dist/unstable-core-do-not-import/stream/sse.d.ts:45:76 - error TS2315: Type 'ReadableStream' is not generic.

45 export declare function sseStreamProducer(opts: SSEStreamProducerOptions): ReadableStream<string>;
~~~~~~~~~~~~~~~~~~~~~~

node_modules/@trpc/server/dist/unstable-core-do-not-import/stream/sse.d.ts:57:11 - error TS2304: Cannot find name 'EventSource'.

57 from: EventSource;
~~~~~~~~~~~


Found 5 errors in 2 files.

Errors Files
3 node_modules/@trpc/server/dist/unstable-core-do-not-import/stream/jsonl.d.ts:6
2 node_modules/@trpc/server/dist/unstable-core-do-not-import/stream/sse.d.ts:45
tsc --declaration --emitDeclarationOnly


added 249 packages, and audited 523 packages in 3s

40 packages are looking for funding
run `npm fund` for details

found 0 vulnerabilities
node_modules/@trpc/server/dist/unstable-core-do-not-import/stream/jsonl.d.ts:6:22 - error TS2304: Cannot find name 'ReadableStreamDefaultReader'.

6 getReader: () => ReadableStreamDefaultReader<Uint8Array>;
~~~~~~~~~~~~~~~~~~~~~~~~~~~

node_modules/@trpc/server/dist/unstable-core-do-not-import/stream/jsonl.d.ts:82:69 - error TS2315: Type 'ReadableStream' is not generic.

82 export declare function jsonlStreamProducer(opts: ProducerOptions): ReadableStream<Uint8Array>;
~~~~~~~~~~~~~~~~~~~~~~~~~~

node_modules/@trpc/server/dist/unstable-core-do-not-import/stream/jsonl.d.ts:103:21 - error TS2304: Cannot find name 'ReadableStreamDefaultController'.

103 controller: ReadableStreamDefaultController<ChunkData | StreamInterruptedError>;
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

node_modules/@trpc/server/dist/unstable-core-do-not-import/stream/sse.d.ts:45:76 - error TS2315: Type 'ReadableStream' is not generic.

45 export declare function sseStreamProducer(opts: SSEStreamProducerOptions): ReadableStream<string>;
~~~~~~~~~~~~~~~~~~~~~~

node_modules/@trpc/server/dist/unstable-core-do-not-import/stream/sse.d.ts:57:11 - error TS2304: Cannot find name 'EventSource'.

57 from: EventSource;
~~~~~~~~~~~


Found 5 errors in 2 files.

Errors Files
3 node_modules/@trpc/server/dist/unstable-core-do-not-import/stream/jsonl.d.ts:6
2 node_modules/@trpc/server/dist/unstable-core-do-not-import/stream/sse.d.ts:45
Solution:
fixed by adding the "DOM" lib to my TS config
Jump to solution
2 Replies
Evan
EvanOP3mo ago
Here is my server:

import { initTRPC } from "@trpc/server";
import type { CreateAWSLambdaContextOptions } from "@trpc/server/adapters/aws-lambda";
import { awsLambdaRequestHandler } from "@trpc/server/adapters/aws-lambda";
import type { APIGatewayProxyEvent } from "aws-lambda";

function createContext({
event,
}: CreateAWSLambdaContextOptions<APIGatewayProxyEvent>) {

return {
event: event,
apiVersion: (event as { version?: string }).version ?? "1.0",
user: event.headers["x-user"],
};
}
type Context = Awaited<ReturnType<typeof createContext>>;

const t = initTRPC.context<Context>().create();

const router = t.router;

const appRouter = router(...);

export type AppRouter = typeof appRouter;

export const handler = awsLambdaRequestHandler({
router: appRouter,
createContext,

});

import { initTRPC } from "@trpc/server";
import type { CreateAWSLambdaContextOptions } from "@trpc/server/adapters/aws-lambda";
import { awsLambdaRequestHandler } from "@trpc/server/adapters/aws-lambda";
import type { APIGatewayProxyEvent } from "aws-lambda";

function createContext({
event,
}: CreateAWSLambdaContextOptions<APIGatewayProxyEvent>) {

return {
event: event,
apiVersion: (event as { version?: string }).version ?? "1.0",
user: event.headers["x-user"],
};
}
type Context = Awaited<ReturnType<typeof createContext>>;

const t = initTRPC.context<Context>().create();

const router = t.router;

const appRouter = router(...);

export type AppRouter = typeof appRouter;

export const handler = awsLambdaRequestHandler({
router: appRouter,
createContext,

});
looking online it seems like this might be an issue with typescript and node/browser types? i'm on the latest TS
Solution
Evan
Evan3mo ago
fixed by adding the "DOM" lib to my TS config