Title: Generic React HOC: `TypeError: Cannot read property 'declarations' of undefined` · Issue #41616 · microsoft/TypeScript · GitHub
Open Graph Title: Generic React HOC: `TypeError: Cannot read property 'declarations' of undefined` · Issue #41616 · microsoft/TypeScript
X Title: Generic React HOC: `TypeError: Cannot read property 'declarations' of undefined` · Issue #41616 · microsoft/TypeScript
Description: TypeScript Version: 4.1.2 Search Terms: TypeError Cannot read property declarations of undefined Code src-file1.tsx: import React from "react"; type Tags = "span" | "div"; export const Hoc =
Open Graph Description: TypeScript Version: 4.1.2 Search Terms: TypeError Cannot read property declarations of undefined Code src-file1.tsx: import React from "react"; type Tags = "span" | "div"; export const Hoc = X Description: TypeScript Version: 4.1.2 Search Terms: TypeError Cannot read property declarations of undefined Code src-file1.tsx: import React from "react"; type Tags = "span" | "div&qu...
Opengraph URL: https://github.com/microsoft/TypeScript/issues/41616
X: @github
Domain: github.com
Links:
Viewport: width=device-width
Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Generic React HOC: `TypeError: Cannot read property 'declarations' of undefined`","articleBody":"\u003c!-- 🚨 STOP 🚨 STOP 🚨 STOP 🚨\r\n\r\nHalf of all issues filed here are duplicates, answered in the FAQ, or not appropriate for the bug tracker. Even if you think you've found a *bug*, please read the FAQ first, especially the Common \"Bugs\" That Aren't Bugs section!\r\n\r\nPlease help us by doing the following steps before logging an issue:\r\n * Search: https://github.com/Microsoft/TypeScript/search?type=Issues\r\n * Read the FAQ: https://github.com/Microsoft/TypeScript/wiki/FAQ\r\n\r\nPlease fill in the *entire* template below.\r\n-->\r\n\r\n\u003c!--\r\nPlease try to reproduce the issue with the latest published version. It may have 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\n**TypeScript Version:** 4.1.2\r\n\r\n\u003c!-- Search terms you tried before logging this (so others can find this issue more easily) -->\r\n**Search Terms:** TypeError Cannot read property declarations of undefined\r\n\r\n**Code**\r\n`src-file1.tsx`:\r\n```ts\r\nimport React from \"react\";\r\n\r\ntype Tags = \"span\" | \"div\";\r\n\r\nexport const Hoc = \u003cTag extends Tags>(\r\n\tTagElement: Tag,\r\n): React.FunctionComponent => {\r\n\tconst Component = () => \u003cTagElement />;\r\n\treturn Component;\r\n};\r\n```\r\n`src-file2.tsx`:\r\n```ts\r\nimport React from \"react\";\r\n\r\ntype Tags = \"span\" | \"div\";\r\n\r\nexport const Hoc = (TagElement: Tags): React.FunctionComponent => {\r\n\tconst Component = () => \u003cTagElement />;\r\n\treturn Component;\r\n};\r\n```\r\n\r\n**Expected behavior:**\r\nBoth `npx tsc --strict --noEmit --jsx 'react' src-file1.tsx` and `npx tsc --strict --noEmit --jsx 'react' src-file2.tsx` will run successfully.\r\n\r\n**Actual behavior:**\r\n`npx tsc --strict --noEmit --jsx 'react' src-file2.tsx` runs successfully, but `npx tsc --strict --noEmit --jsx 'react' src-file1.tsx` fails with the error message (where `\"$PWD\"` is the present working directory and `\"$HOME\"` is my home directory):\r\n```\r\n\"$PWD\"/node_modules/typescript/lib/tsc.js:87001\r\n throw e;\r\n ^\r\n\r\nTypeError: Cannot read property 'declarations' of undefined\r\n at addImplementationSuccessElaboration (\"$PWD\"/node_modules/typescript/lib/tsc.js:57022:116)\r\n at resolveCall (\"$PWD\"/node_modules/typescript/lib/tsc.js:56947:33)\r\n at resolveJsxOpeningLikeElement (\"$PWD\"/node_modules/typescript/lib/tsc.js:57576:20)\r\n at resolveSignature (\"$PWD\"/node_modules/typescript/lib/tsc.js:57597:28)\r\n at getResolvedSignature (\"$PWD\"/node_modules/typescript/lib/tsc.js:57608:26)\r\n at checkJsxOpeningLikeElementOrOpeningFragment (\"$PWD\"/node_modules/typescript/lib/tsc.js:55477:27)\r\n at checkJsxSelfClosingElementDeferred (\"$PWD\"/node_modules/typescript/lib/tsc.js:55058:13)\r\n at checkDeferredNode (\"$PWD\"/node_modules/typescript/lib/tsc.js:64402:21)\r\n at Map.forEach (\u003canonymous>)\r\n at checkDeferredNodes (\"$PWD\"/node_modules/typescript/lib/tsc.js:64373:37)\r\nnpm ERR! code 1\r\nnpm ERR! path \"$PWD\"\r\nnpm ERR! command failed\r\nnpm ERR! command sh -c tsc --strict --noEmit --jsx react --esModuleInterop src-file1.tsx\r\n\r\nnpm ERR! A complete log of this run can be found in:\r\nnpm ERR! \"$HOME\"/.npm/_logs/2020-11-20T20_34_21_223Z-debug.log\r\n```\r\n\r\n**Playground Link:** \u003c!-- A link to a TypeScript Playground \"Share\" link which demonstrates this behavior -->\r\nCompiling [the first source file](https://www.typescriptlang.org/play?ts=4.2.0-dev.20201120#code/JYWwDg9gTgLgBAJQKYEMDG8BmUIjgIilQ3wG4AocmATzCTgBUUBzAZzgF4DWwUA7fHAA+BACbAAbmUpoIfVvAASENJzgAeJszhIAHjCR9R7LawB8ACnIBILQFEANkhCGYALkYsANOQCUH5HQYADoAMQBXPgxgOQBhXEg+V04zOABvG1l5eHjwOWSuC18UjXsnFz54AHozCmsiGHCoPjhcxNcKAF9SIA) crashes the web compiler, \r\n\u003cimg width=\"1437\" alt=\"image\" src=\"https://user-images.githubusercontent.com/47605337/99848688-300a7a00-2bb5-11eb-9946-6cdd4dbcdd3c.png\">\r\n\u003cimg width=\"1439\" alt=\"image\" src=\"https://user-images.githubusercontent.com/47605337/99848710-37ca1e80-2bb5-11eb-8b99-28f1df0a1739.png\">\r\n\u003cimg width=\"1437\" alt=\"image\" src=\"https://user-images.githubusercontent.com/47605337/99848249-65fb2e80-2bb4-11eb-92c6-23df11816a20.png\">\r\nwhile compiling [the second source file](https://www.typescriptlang.org/play?ts=4.2.0-dev.20201120#code/JYWwDg9gTgLgBAJQKYEMDG8BmUIjgIilQ3wG4AocmATzCTgBUUBzAZzgF4DWwUA7fHAA+BACbAAbmUpoIfVvAASENJzgAKJswCiAGyQgkfGAC5GLVgEozydDAB0AMQCufDMDkBhXJD5H4HAB8cADe5ACQsvLw3uBy-mrqlpzBADxaegYJAPSBFOFEMM5QfHCxvv4UAL6kQA) succeeds.\r\n\u003cimg width=\"1437\" alt=\"image\" src=\"https://user-images.githubusercontent.com/47605337/99848740-44e70d80-2bb5-11eb-971b-b5e4f4c1bcf0.png\">\r\n\u003cimg width=\"1437\" alt=\"image\" src=\"https://user-images.githubusercontent.com/47605337/99848759-4b758500-2bb5-11eb-9dca-3cd5f88d2958.png\">\r\n\u003cimg width=\"1438\" alt=\"image\" src=\"https://user-images.githubusercontent.com/47605337/99848543-ee79cf00-2bb4-11eb-805e-bbc5b37a132e.png\">\r\n\r\n**Related Issues:** \u003c!-- Did you find other bugs that looked similar? -->\r\n#33735 #21817 #21811 #21798 #20475 #6428","author":{"url":"https://github.com/mingcenwei","@type":"Person","name":"mingcenwei"},"datePublished":"2020-11-20T20:57:36Z","url":"https://github.com/microsoft/TypeScript/issues/41616"}
react-profiling 0 react-import-map react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 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:70cbc56d-11c4-fb41-f708-972595edbe66 current-catalog-service-hash 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 request-id 9F8E:1F2D:207B139:29243C9:6B01A70B html-safe-nonce 845ff29dec201bb1e6075a8efc1c55a425818c50f73f7f453ff0c4c10d97a0bf visitor-payload eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5RjhFOjFGMkQ6MjA3QjEzOToyOTI0M0M5OjZCMDFBNzBCIiwidmlzaXRvcl9pZCI6IjM4NTc3NTE0ODU0NjcxNzQ2NjciLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== visitor-hmac b9f4ce4f05aeab6bf71fc247d69f2d24806432697b8ff98f7907b674ab78245a hovercard-subject-tag issue:747788587 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/41616/issue_layout twitter:image https://opengraph.githubassets.com/4ab1af16c0644c26557809e261043ae663d126a7a14e9a4e8b48627304705239/microsoft/TypeScript/issues/41616 twitter:card summary_large_image og:image https://opengraph.githubassets.com/4ab1af16c0644c26557809e261043ae663d126a7a14e9a4e8b48627304705239/microsoft/TypeScript/issues/41616 og:image:alt TypeScript Version: 4.1.2 Search Terms: TypeError Cannot read property declarations of undefined Code src-file1.tsx: import React from "react"; type Tags = "span" | "div"; export const Hoc = og:image:width 1200 og:image:height 600 og:site_name GitHub og:type object og:author:username mingcenwei hostname github.com expected-hostname github.com None cc5dfdd32f62ebd3223cab3af3aa2b268d3605218237326a48a99d1efd89495c 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 8c77c9e8439031ad54c75a250694842892f693e1 ui-target full theme-color #1e2327 color-scheme light dark react-app-name issues
URLs of crawlers that visited me.