jmac
jmac2mo ago

tRPC v11 FileLike

Hey there, using stable version of v11 now and following the example (https://github.com/trpc/trpc/blob/main/examples/minimal-content-types/server/index.ts) throws some Typescript errors regarding the FileLike interface Exported variable 'router' has or is using name 'FileLike' from external module "/node_modules/@trpc/server/dist/unstable-core-do-not-import/http/contentTypeParsers" but cannot be named. Node version: v20.17 using pnpm This is specifically when I'm importing import { octetInputParser } from "@trpc/server/http"; and using it like so:
upload: protectedProcedure
.input(octetInputParser)
.mutation(async ({ input }) => {
const chunks = [];

const reader = input.getReader();
while (true) {
const { done, value } = await reader.read();
if (done) {
break;
}
chunks.push(value);
}

const content = Buffer.concat(chunks).toString("utf-8");

console.log("File: ", content);

return {
text: "ACK",
data: content,
};
}),
upload: protectedProcedure
.input(octetInputParser)
.mutation(async ({ input }) => {
const chunks = [];

const reader = input.getReader();
while (true) {
const { done, value } = await reader.read();
if (done) {
break;
}
chunks.push(value);
}

const content = Buffer.concat(chunks).toString("utf-8");

console.log("File: ", content);

return {
text: "ACK",
data: content,
};
}),
GitHub
trpc/examples/minimal-content-types/server/index.ts at main · trpc...
🧙‍♀️ Move Fast and Break Nothing. End-to-end typesafe APIs made easy. - trpc/trpc
4 Replies
Nick
Nick2w ago
Ahh we’re familiar with this type of error, it does pop up occasionally Without a reproduction (can just be a link to a random codebase on github or stackblitz) it’s hard to say if it’s your setup or our fault though
jmac
jmacOP2w ago
@Nick Sorry for the delay, This is a codebase that is legit from t3 turbo and then added a documents router in the api package https://github.com/joelmce/trpc-file-example
GitHub
GitHub - joelmce/trpc-file-example
Contribute to joelmce/trpc-file-example development by creating an account on GitHub.
Nick
Nick2w ago
Thanks, could you pop this in a github issue? We can have a look then
jmac
jmacOP2w ago
Done -- thanks. For those following: https://github.com/trpc/trpc/issues/6710
GitHub
bug: Exported variable 'router' has or is using name 'FileLike' fro...
Provide environment information System: OS: macOS 14.1 CPU: (11) arm64 Apple M3 Pro Memory: 115.78 MB / 18.00 GB Shell: 5.9 - /bin/zsh Binaries: Node: 20.17.0 - /opt/homebrew/bin/node npm: 11.0.0 -...

Did you find this page helpful?