Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bug: The inferred type of 'appRouter' cannot be named without a reference to ... #2994

Closed
1 task done
echocrow opened this issue Oct 12, 2022 · 0 comments · Fixed by #2999
Closed
1 task done

bug: The inferred type of 'appRouter' cannot be named without a reference to ... #2994

echocrow opened this issue Oct 12, 2022 · 0 comments · Fixed by #2999

Comments

@echocrow
Copy link
Contributor

echocrow commented Oct 12, 2022

Provide environment information

Local machine:

envinfo: command not found

¯\_(ツ)_/¯

Stackblitz repro:

  System:
    OS: Linux 5.0 undefined
    CPU: (6) x64 Intel(R) Core(TM) i9-9880H CPU @ 2.30GHz
    Memory: 0 Bytes / 0 Bytes
    Shell: 1.0 - /bin/jsh
  Binaries:
    Node: 16.14.2 - /usr/local/bin/node
    Yarn: 1.22.10 - /usr/local/bin/yarn
    npm: 7.17.0 - /usr/local/bin/npm
  npmPackages:
    @trpc/server: 10.0.0-proxy-beta.18 => 10.0.0-proxy-beta.18 
    typescript: ^4.8 => 4.8.4 

Describe the bug

Under "moduleResolution": "Node16" (or "NodeNext"), compilation of TypeScript types for the router can fail with error

TS2742: The inferred type of 'appRouter' cannot be named without a reference to '../node_modules/@trpc/server/dist/core/internals/config.js'. This is likely not portable. A type annotation is necessary.

Link to reproduction

https://stackblitz.com/edit/trpc-server-inferred-type-cannot-be-named?file=src%2Findex.ts&view=editor

To reproduce

See repro:

  1. Set up package with Typescript
  2. Set "moduleResolution": "Node16"
  3. Try to compile types, e.g. via tsc --declaration

Additional information

Related issues:

Tried several suggested solutions (e.g. mentioned here); none worked, or had undesired side-effects.

The same issue exists in 9.x (after having manually worked around the module resolution).

👨‍👧‍👦 Contributing

  • 🙋‍♂️ Yes, I'd be down to file a PR fixing this bug!
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Oct 28, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant