rd
rdβ€’14mo ago

All values in DecoratedProcedureRecord are of type any

I've stumbled across an issue and I'm not sure how to start diagnosing it... Basically in my IDE the return type of my createTRPCProxyClient<AppRouter>(...) call is a DecoratedProcedureRecord where every value is of type any. I'm seeing a lot of issues with TS seemingly struggling to work with this repo, I suspect that the types have become too complex with tRPC and the ORM I'm using. Is it possible that TS has just "given up" so returns any instead of the expected type? Or is it likely something else?
7 Replies
rd
rdβ€’14mo ago
I've tried stripping down the router to a single merge with one procedure though and it's still of type any πŸ€·β€β™‚οΈ Ah, I think it's related to using paths in a ts-config in a monorepo, seems like the consuming package potentially can't resolve the imports
Nick
Nickβ€’14mo ago
Can you share your project structure and the tsconfig for the client?
rd
rdβ€’14mo ago
I can if it would be helpful, anything specifically? I'm certain this isn't a tRPC issue now though, I removed path aliases from the internal package/tsconfig and the types reappeared.
Nick
Nickβ€’14mo ago
Yeah it’s more project setup, but we treat that as something we can generally help figure out!
rd
rdβ€’14mo ago
Not sure if this is clear or not! Appreciate the help but no pressure of course πŸ™‚
tsconfig.json
- apps
- client
- tsconfig.json
- server
- tsconfig.json
tsconfig.json
- apps
- client
- tsconfig.json
- server
- tsconfig.json
root tsconfig:
{
"files": [],
"references": [
{
"path": "./apps/server"
},
{
"path": "./apps/client"
},
]
}
{
"files": [],
"references": [
{
"path": "./apps/server"
},
{
"path": "./apps/client"
},
]
}
server tsconfig:
{
"compilerOptions": {
"baseUrl": ".",
"composite": false,
"declaration": false,
"declarationMap": false,
"esModuleInterop": true,
"inlineSources": false,
"isolatedModules": true,
"module": "CommonJS",
"moduleResolution": "node",
"noUnusedLocals": false,
"noUnusedParameters": false,
"outDir": "./dist",
"rootDir": "./src",
"skipLibCheck": true,
"strict": true,
"target": "ES2022",
"types": ["vitest/globals", "node"],
"paths": {
"@/*": ["./src/*"]
}
},
"include": ["src"],
"exclude": ["node_modules", "src/**/*.spec.ts", "src/**/*.test.ts"],
"ts-node": {
"require": ["tsconfig-paths/register"],
"transpileOnly": false
}
}
{
"compilerOptions": {
"baseUrl": ".",
"composite": false,
"declaration": false,
"declarationMap": false,
"esModuleInterop": true,
"inlineSources": false,
"isolatedModules": true,
"module": "CommonJS",
"moduleResolution": "node",
"noUnusedLocals": false,
"noUnusedParameters": false,
"outDir": "./dist",
"rootDir": "./src",
"skipLibCheck": true,
"strict": true,
"target": "ES2022",
"types": ["vitest/globals", "node"],
"paths": {
"@/*": ["./src/*"]
}
},
"include": ["src"],
"exclude": ["node_modules", "src/**/*.spec.ts", "src/**/*.test.ts"],
"ts-node": {
"require": ["tsconfig-paths/register"],
"transpileOnly": false
}
}
client tsconfig:
{
"extends": "@vue/tsconfig/tsconfig.dom.json",
"include": ["env.d.ts", "src/**/*", "src/**/*.vue"],
"compilerOptions": {
"baseUrl": ".",
"paths": {
"@/*": ["./src/*"]
},
"lib": ["ES2016", "DOM", "DOM.Iterable"]
}
}
{
"extends": "@vue/tsconfig/tsconfig.dom.json",
"include": ["env.d.ts", "src/**/*", "src/**/*.vue"],
"compilerOptions": {
"baseUrl": ".",
"paths": {
"@/*": ["./src/*"]
},
"lib": ["ES2016", "DOM", "DOM.Iterable"]
}
}
Nick
Nickβ€’14mo ago
Do you have separate package.json files or just one in the root? or you're using npm workspaces? Often adding the server file which exports the AppRouter to the client's tsconfig "include" fixes a lot of issues (via relative path) If you then run into anything complaining about non-portable types that would generally happen when you have separate node_modules folders via separate package.json files. Using workspaces with hoisting, or installing in the root can help there
rd
rdβ€’14mo ago
Hey thanks, yes separate package.json files, using turborepo and npm workspaces (I think), all dependencies are installed in the root node_modules dir. I'll see if adding the server file to "include" helps, appreciate the advice πŸ™‚