Bug Report
🔎 Search Terms
inferred type cannot be named, symlink node_modules
🕗 Version & Regression Information
I'm verifying the problem on the typescript@4.1.3. I've not tried older versions but at least is also reproducible on the @next version as of today.
It is probably a regression or a corner case related with other issues opened and already closed like:
⏯ Playground Link
Link for a repo where the problem is being reproduced
NOTE: Just clone the repo and run yarn tsc
💻 Code
All the relevant code can be found at https://github.com/mistic/reproduce-typescript-problem-when-symlinking-node_modules
It is just reproducing a similar setup that I had on other project that was generating the problem:
- node_modules are a symlink to another location that is not a direct parent of the symlinked node_modules
- we are using types in the compilation from a library where those types are just exported from other one, like for example
withRouter within react-router-dom that is just a plain export from the same type on react-router.
🙁 Actual behavior
I got the following error:
error TS2742: The inferred type of 'Nav' cannot be named without a reference to '../../deps/node_modules/@types/react-router'. This is likely not portable. A type annotation is necessary.
8 export const Nav = withRouter(({ history }: NavProps) => {
~~~
Found 1 error.
🙂 Expected behavior
I was expecting no error at all and that the typescript compiler was just able to find all the respective modules. I've tried everything that I thought was related like enabled the preserveSymlinks. The only thing that stops the error is importing the withRouter type directly from react-router and not from react-router-dom but that doesn't make very sense because I actually want to use the react-router-dom on a couple of places.
\cc @weswigham @sheetalkamat @andrewbranch because I saw you previously worked to try to solve similar issues.
Bug Report
🔎 Search Terms
inferred type cannot be named, symlink node_modules
🕗 Version & Regression Information
I'm verifying the problem on the
typescript@4.1.3. I've not tried older versions but at least is also reproducible on the@nextversion as of today.It is probably a regression or a corner case related with other issues opened and already closed like:
⏯ Playground Link
Link for a repo where the problem is being reproduced
💻 Code
All the relevant code can be found at https://github.com/mistic/reproduce-typescript-problem-when-symlinking-node_modules
It is just reproducing a similar setup that I had on other project that was generating the problem:
withRouterwithinreact-router-domthat is just a plain export from the same type onreact-router.🙁 Actual behavior
I got the following error:
🙂 Expected behavior
I was expecting no error at all and that the typescript compiler was just able to find all the respective modules. I've tried everything that I thought was related like enabled the
preserveSymlinks. The only thing that stops the error is importing thewithRoutertype directly fromreact-routerand not fromreact-router-dombut that doesn't make very sense because I actually want to use thereact-router-domon a couple of places.\cc @weswigham @sheetalkamat @andrewbranch because I saw you previously worked to try to solve similar issues.