SchnozzleCat
SchnozzleCat4mo ago

Type inference issues after upgrading to Typescript 5+

After upgrading an API consuming project from typescript 4 to 5, my calls to .query are inferred to any instead of the actual type. I've tried a bunch of different things but can't seem to get it to work. I also couldn't find anything specifically related to this wrt. TS5. I'm assuming the issue is that some compiler settings changed, and this is somehow breaking the import. What's strange is that the AppRouter imported from the referenced project seems to have the correct shape, but somehow calling a query on the router instance still fails.
No description
No description
2 Replies
SchnozzleCat
SchnozzleCatOP4mo ago
The issue also persists under TRPC 11 This is the tsconfig of the consuming project:
{
"compilerOptions": {
"target": "ES2020",
"lib": ["dom", "dom.iterable", "esnext"],
"allowJs": true,
"skipLibCheck": true,
"strict": true,
"noEmit": true,
"esModuleInterop": true,
"module": "esnext",
"moduleResolution": "node",
"resolveJsonModule": true,
"isolatedModules": true,
"jsx": "preserve",
"incremental": true,
"importsNotUsedAsValues": "remove",
"preserveValueImports": false,
"isolatedModules": false,
"plugins": [
{
"name": "next"
}
],
"paths": {
"@/*": ["./src/*"],
"api/*": ["../api/dist/*"]
}
},
"references": [
{
"path": "../api"
}
]
}
{
"compilerOptions": {
"target": "ES2020",
"lib": ["dom", "dom.iterable", "esnext"],
"allowJs": true,
"skipLibCheck": true,
"strict": true,
"noEmit": true,
"esModuleInterop": true,
"module": "esnext",
"moduleResolution": "node",
"resolveJsonModule": true,
"isolatedModules": true,
"jsx": "preserve",
"incremental": true,
"importsNotUsedAsValues": "remove",
"preserveValueImports": false,
"isolatedModules": false,
"plugins": [
{
"name": "next"
}
],
"paths": {
"@/*": ["./src/*"],
"api/*": ["../api/dist/*"]
}
},
"references": [
{
"path": "../api"
}
]
}

Did you find this page helpful?