Title: The inferred type of "X" cannot be named without a reference to "Y". This is likely not portable. A type annotation is necessary. · Issue #42873 · microsoft/TypeScript · GitHub
Open Graph Title: The inferred type of "X" cannot be named without a reference to "Y". This is likely not portable. A type annotation is necessary. · Issue #42873 · microsoft/TypeScript
X Title: The inferred type of "X" cannot be named without a reference to "Y". This is likely not portable. A type annotation is necessary. · Issue #42873 · microsoft/TypeScript
Description: 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 @n...
Open Graph Description: 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...
X Description: 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 ...
Opengraph URL: https://github.com/microsoft/TypeScript/issues/42873
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"The inferred type of \"X\" cannot be named without a reference to \"Y\". This is likely not portable. A type annotation is necessary.","articleBody":"# Bug Report\r\n\r\n\u003c!--\r\n Please fill in each section completely. Thank you!\r\n--\u003e\r\n\r\n### 🔎 Search Terms\r\n\r\n\u003c!--\r\n What search terms did you use when trying to find an existing bug report?\r\n List them here so people in the future can find this one more easily.\r\n--\u003e\r\n\r\ninferred type cannot be named, symlink node_modules\r\n\r\n### 🕗 Version \u0026 Regression Information\r\n\r\n\u003c!-- When did you start seeing this bug occur?\r\n\r\n\"Bugs\" that have existed in TS for a long time are very likely to be FAQs; refer to\r\n https://github.com/Microsoft/TypeScript/wiki/FAQ#common-bugs-that-arent-bugs\r\n\r\nIf possible, please try testing the nightly version of TS to see if it's already been fixed.\r\nFor npm: `typescript@next`\r\nThis is also the 'Nightly' version in the playground: http://www.typescriptlang.org/play/?ts=Nightly\r\n\r\nNote: The TypeScript Playground can be used to try older versions of TypeScript.\r\n\r\nPlease keep and fill in the line that best applies:\r\n--\u003e\r\nI'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.\r\n\r\nIt is probably a regression or a corner case related with other issues opened and already closed like:\r\n\r\n- https://github.com/microsoft/TypeScript/issues/30858\r\n- https://github.com/microsoft/TypeScript/issues/28689\r\n- https://github.com/microsoft/TypeScript/issues/2338\r\n- https://github.com/microsoft/TypeScript/issues/29221\r\n\r\n### ⏯ Playground Link\r\n\r\n\u003c!--\r\n A link to a TypeScript Playground \"Share\" link which shows this behavior\r\n\r\n The TypeScript Workbench can be used for more complex setups, try\r\n https://www.typescriptlang.org/dev/bug-workbench/\r\n\r\n As a last resort, you can link to a repo, but these will be slower for us to investigate.\r\n--\u003e\r\n[Link for a repo where the problem is being reproduced](https://github.com/mistic/reproduce-typescript-problem-when-symlinking-node_modules)\r\n\r\n\u003e NOTE: Just clone the repo and run `yarn tsc`\r\n\r\n### 💻 Code\r\n\r\n\u003c!-- Please post the relevant code sample here as well--\u003e\r\n\r\nAll the relevant code can be found at https://github.com/mistic/reproduce-typescript-problem-when-symlinking-node_modules\r\n\r\nIt is just reproducing a similar setup that I had on other project that was generating the problem:\r\n\r\n- node_modules are a symlink to another location that is not a direct parent of the symlinked node_modules\r\n- 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`.\r\n\r\n### 🙁 Actual behavior\r\n\r\nI got the following error:\r\n\r\n```\r\nerror 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.\r\n\r\n8 export const Nav = withRouter(({ history }: NavProps) =\u003e {\r\n ~~~\r\n\r\n\r\nFound 1 error.\r\n```\r\n### 🙂 Expected behavior\r\n\r\n\u003c!-- What you expected to happen instead, and why --\u003e\r\n\r\nI 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.\r\n\r\n\\cc @weswigham @sheetalkamat @andrewbranch because I saw you previously worked to try to solve similar issues. \r\n","author":{"url":"https://github.com/mistic","@type":"Person","name":"mistic"},"datePublished":"2021-02-19T00:03:21.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":136},"url":"https://github.com/42873/TypeScript/issues/42873"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:6f812e47-d185-327b-3ae6-9ce61bce9131 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 8B9A:324D9E:1001A6F:16F5564:6A5F9121 |
| html-safe-nonce | 862792c5a13bdae4b61cb93a16554e30d581a7282ecaca10a66da876f3f395ac |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4QjlBOjMyNEQ5RToxMDAxQTZGOjE2RjU1NjQ6NkE1RjkxMjEiLCJ2aXNpdG9yX2lkIjoiMzU5NzQzMTAyNjU2NDk2MDU0NSIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | bfd8643cc2c8d68f5f4dd46e9026f354bb8e00c29f32390d202cae1be913cbd6 |
| hovercard-subject-tag | issue:811568342 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/microsoft/TypeScript/42873/issue_layout |
| twitter:image | https://opengraph.githubassets.com/b74d058b2802aac2c9fc6912354d23b2530257b72b9624d894d66dabdac3c2f3/microsoft/TypeScript/issues/42873 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/b74d058b2802aac2c9fc6912354d23b2530257b72b9624d894d66dabdac3c2f3/microsoft/TypeScript/issues/42873 |
| og:image:alt | 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... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | mistic |
| hostname | github.com |
| expected-hostname | github.com |
| None | 419b66b5f218029570caa18c30987e7dbabe4f5a6767918b33a504d02739c9c7 |
| turbo-cache-control | no-preview |
| go-import | github.com/microsoft/TypeScript git https://github.com/microsoft/TypeScript.git |
| octolytics-dimension-user_id | 6154722 |
| octolytics-dimension-user_login | microsoft |
| octolytics-dimension-repository_id | 20929025 |
| octolytics-dimension-repository_nwo | microsoft/TypeScript |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 20929025 |
| octolytics-dimension-repository_network_root_nwo | microsoft/TypeScript |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | de5b18aa36dbc0b61e03aeb111e84e90fde499b8 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width