maddest
maddest12mo ago

TRPCError class, public readonly cause?: Error; this line should have override function

hey i am trying to use the TRPCError for throwing errors in my apps, but i am getting this error, changing the line from public readonly cause?: Error; to public override readonly cause?: Error; fixes the problem the problem but i am doing that in node_modules which is not how this gets resolved, how do i resolve this? when trying to use module arugmentation, i am getting an dupliate declare class error meaning the TRPCError class has already be declared in TRPCError.d.ts file please help me resolve this issue, my @trpc/server and @trpc/client version is
"@trpc/client": "^10.38.5",
"@trpc/server": "^10.38.5",
"@trpc/client": "^10.38.5",
"@trpc/server": "^10.38.5",
my typescript version is above 5 i am using turborepo, this error was not there before, but since i was doing some migration of my trpc code to a seperate trpc package, i am getting these errrors
14 Replies
maddest
maddestOP12mo ago
this is the error when i am building my project
No description
Nick
Nick12mo ago
Hm, what node and typescript versions are you running? Might be related to a change there and something we need to address (feel free to make a github issue if you can do a small reproduction somewhere)
maddest
maddestOP12mo ago
node is 20 typescript , 5.3.3 on doing some searching found that typescript after some 4.2.4 version introduced some change related to this, idk have any idea, but giving as much details i can
Nick
Nick12mo ago
Yeah it would have to be far more recent, or some flag you’ve got switched on in tsconfig that we aren’t aware of Those are quite new versions so it’s possible something has changed
maddest
maddestOP12mo ago
that to i know of, tsconfig has been same since my last push but what instead i have done is just made a seperate trpc package outside my api package (which just had enpoint logics) i raised the issue on trpc repository
Nick
Nick12mo ago
Thanks, we’ll be able to to take a look at that repro and hopefully come up with a solution or documentation. if you have a workaround for now that’s great though
Nick
Nick12mo ago
Ah that might be it, just threw that in the core chat
No description
maddest
maddestOP12mo ago
oh shi-, that did fixed it, thanks it literally saved me several hours of works finding work around and module argumenting this should i close that issue or comment there that person should have noImplicitOverride field should not be set to true in their tsconfig unless then are using ts version <=4.2
Nick
Nick12mo ago
Please do add the solution to the issue, it will help future people 🙂 Feel free to close if you’re happy it’s resolved. Might be something we could support properly though
kamilogorek
kamilogorek12mo ago
tRPC requires at least TypeScript v4.7, so you can also send a PR that'll update all overrides 🙂 this way you, and other people can keep using this config setting It's TRPCError and TRPCClientError only from what I see that need to be updated
maddest
maddestOP12mo ago
yeah i would be very happy to fix this by raising a pr, okay on it
maddest
maddestOP12mo ago
hey @kamilogorek , sorry for tagging you, i had a doubt, on adding override on my codebase in trpc/server node_modules, i am not getting error during build (basically fix the issue), but i am getting this red error that, i can't use override keyword because there is no field named cause in Error class as you can see, but , my app is using lib.es5.d.ts but the trpc i cloned was using the lib.es2022.d.ts which did not give this error just wanted to make sure if this has nothing to do,
No description
kamilogorek
kamilogorek12mo ago
Casue requires indeed es2022 to be recognized, so you’ll be fine 🙂
maddest
maddestOP12mo ago
got it 👍 , thanks for your time i raised the pr, please let me know if there is something..