Title: strictFunctionTypes on a large type with higher-order functions causes tsserver to hang with "Loading..." in VS Code · Issue #30449 · microsoft/TypeScript · GitHub
Open Graph Title: strictFunctionTypes on a large type with higher-order functions causes tsserver to hang with "Loading..." in VS Code · Issue #30449 · microsoft/TypeScript
X Title: strictFunctionTypes on a large type with higher-order functions causes tsserver to hang with "Loading..." in VS Code · Issue #30449 · microsoft/TypeScript
Description: TypeScript Version: 3.4.0-dev.20190316 Search Terms: loading, stuck Code I tried to create an array which represented the full key type of JSX.IntrinsicElements. I ended up being able to narrow down the issue to this case. If I simply sp...
Open Graph Description: TypeScript Version: 3.4.0-dev.20190316 Search Terms: loading, stuck Code I tried to create an array which represented the full key type of JSX.IntrinsicElements. I ended up being able to narrow dow...
X Description: TypeScript Version: 3.4.0-dev.20190316 Search Terms: loading, stuck Code I tried to create an array which represented the full key type of JSX.IntrinsicElements. I ended up being able to narrow dow...
Opengraph URL: https://github.com/microsoft/TypeScript/issues/30449
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"strictFunctionTypes on a large type with higher-order functions causes tsserver to hang with \"Loading...\" in VS Code","articleBody":"\u003c!-- 🚨 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!-- Please try to reproduce the issue with `typescript@next`. It may have already been fixed. -->\r\n**TypeScript Version:** 3.4.0-dev.20190316\r\n\r\n\u003c!-- Search terms you tried before logging this (so others can find this issue more easily) -->\r\n**Search Terms:** loading, stuck\r\n\r\n**Code**\r\n\r\n~~I tried to create an array which represented the full key type of `JSX.IntrinsicElements`.~~\r\n\r\n~~I ended up being able to narrow down the issue to this case. If I simply specify the type alias for the key type, and export an array of that type, then import it in another module, that triggers this issue.~~\r\n\r\nThe case that I had was insufficient. I assumed the above was the issue based on looking at my code, but I was able to narrow it down to the below case, **only with strictFunctionTypes turned on**. I'm working on a styled-components clone, and I've started specifying the base API. I was not able to reproduce this with a case simpler than this. It seems that JSX.IntrinsicElements is a large enough interface that it overloads the tsserver. The resulting `Styled` type contains higher-order functions that I'm assuming are too complex to analyze with strictFunctionTypes turned on.\r\n\r\nThese are the things I tried, all of which cause tsserver to behave normally:\r\n* replace `DomKey` with `string`\r\n* replace `JSX.IntrinsicElements` with a smaller interface\r\n* get rid of the `createNew` function and replace `Styled` with `StyledFactories`\r\n* get rid of the non-type code (the last four statements)\r\n* replace `Interpolation` with `string`.\r\n\r\n```ts\r\ntype DomKey = keyof JSX.IntrinsicElements;\r\n\r\ntype StyledFactories = {\r\n [P in DomKey]: StyledConstructor\u003cJSX.IntrinsicElements[P]>\r\n};\r\n\r\ntype Styled = StyledFactories & {\r\n createNew: \u003cP>(tag: React.ComponentType\u003cP>) => StyledConstructor\u003cP>\r\n};\r\n\r\ntype StyledConstructor\u003cP> = (strings: TemplateStringsArray, ...interpolations: Interpolation\u003cP>[]) => React.ComponentType\u003cP>;\r\n\r\ntype Interpolation\u003cP> = string | ((props: P) => Interpolation\u003cP>);\r\n\r\nconst domElements: Array\u003cDomKey> = [];\r\n\r\nconst createNew = \u003cP>(tag: string | React.ComponentType\u003cP>) => {\r\n return (strings: TemplateStringsArray, ...interpolations: Array\u003cInterpolation\u003cP>>) => {}\r\n};\r\n\r\nconst styled: Styled = { createNew };\r\n\r\nfor (const el of domElements) {\r\n styled[el] = createNew(el);\r\n}\r\n```\r\n\r\n**Expected behavior:**\r\n\r\nI am able to get proper IDE integration: mouse-over info, auto-complete, errors/warnings, etc.\r\n\r\n**Actual behavior:**\r\n\r\nAbsolutely nothing. When I mouse over something, it shows a box with the text \"Loading...\" instead of info about the element under the cursor.\r\n\r\nI turned on verbose logging and trace. I'll post each of those in a comment.\r\n\r\n**Playground Link:** \u003c!-- A link to a TypeScript Playground \"Share\" link which demonstrates this behavior --> React is required to reproduce this issue\r\n\r\n**Related Issues:** \u003c!-- Did you find other bugs that looked similar? -->\r\n* https://github.com/Microsoft/TypeScript/issues/3892\r\n","author":{"url":"https://github.com/jchitel","@type":"Person","name":"jchitel"},"datePublished":"2019-03-17T05:24:27Z","url":"https://github.com/microsoft/TypeScript/issues/30449"}
| 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:7f06206b-da41-75be-cf8f-5bdf75a8033b |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 8E68:2C3566:E88446:1342F7E:6B00FEBE |
| html-safe-nonce | 901fad7717e205fe00b059292460e520ef66d9543f6d4a5b57ff673de4fcad5e |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4RTY4OjJDMzU2NjpFODg0NDY6MTM0MkY3RTo2QjAwRkVCRSIsInZpc2l0b3JfaWQiOiIyOTc2NDM3MTAyNzA0NjU2MDYyIiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 0e5f0b6947f78aa2b05b7dfccb8b445706803cf784b96a12ccf5e26548be7c55 |
| hovercard-subject-tag | issue:421883876 |
| 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/30449/issue_layout |
| twitter:image | https://opengraph.githubassets.com/aca8a48b323b0f2813bc08af7ce831d135d376942bc88c8c6b9cf44b857970ce/microsoft/TypeScript/issues/30449 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/aca8a48b323b0f2813bc08af7ce831d135d376942bc88c8c6b9cf44b857970ce/microsoft/TypeScript/issues/30449 |
| og:image:alt | TypeScript Version: 3.4.0-dev.20190316 Search Terms: loading, stuck Code I tried to create an array which represented the full key type of JSX.IntrinsicElements. I ended up being able to narrow dow... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | jchitel |
| hostname | github.com |
| expected-hostname | github.com |
| None | cb7fa109eca7d4156c889f474306b0e91336055e9adf8fd4684b61e49094d124 |
| 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 | 2b59d31a4e44f08b7af67a4b67f8fd0af3befe2a |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width