Title: TS Server: Return description of why a given refactoring cannot be applied · Issue #35098 · microsoft/TypeScript · GitHub
Open Graph Title: TS Server: Return description of why a given refactoring cannot be applied · Issue #35098 · microsoft/TypeScript
X Title: TS Server: Return description of why a given refactoring cannot be applied · Issue #35098 · microsoft/TypeScript
Description: Follow up on #34930 Search terms refactor / refactoring Problem In VS Code, I often try to extract something to a function only to discover that this is not possible for the my current selection. The current UX for this is poor, since we...
Open Graph Description: Follow up on #34930 Search terms refactor / refactoring Problem In VS Code, I often try to extract something to a function only to discover that this is not possible for the my current selection. T...
X Description: Follow up on #34930 Search terms refactor / refactoring Problem In VS Code, I often try to extract something to a function only to discover that this is not possible for the my current selection. T...
Opengraph URL: https://github.com/microsoft/TypeScript/issues/35098
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"TS Server: Return description of why a given refactoring cannot be applied","articleBody":"Follow up on #34930\r\n\r\n**Search terms**\r\n- refactor / refactoring\r\n\r\n## Problem\r\nIn VS Code, I often try to extract something to a function only to discover that this is not possible for the my current selection. The current UX for this is poor, since we offer no explanation of why the selection is not extractable.\r\n\r\n## Proposal\r\nTo fix this, we would like to have TS Server return a human readable message about why a refactoring cannot be applied. Client could then surface this information to users\r\n\r\nWith this proposal, TS Server would no silently longer dropping invalid refactorings like it does today and instead always return them but with an additional error message attached..\r\n\r\n## Protocol proposal\r\nI believe this simplest approach is to add a new `errorDescription` field on `ApplicableRefactorInfo`:\r\n\r\n```ts\r\ninterface ApplicableRefactorInfo {\r\n name: string;\r\n description: string;\r\n inlineable?: boolean;\r\n actions: RefactorActionInfo[];\r\n\r\n errorDescription?: string;\r\n}\r\n```\r\n\r\nClient would be expected to not to try to resolve invalid refactorings.\r\n\r\nTo implement this in a way that won't break existing clients, we also need a way for a client to express that they can handle these invalid refactorings:\r\n\r\n```ts\r\ninterface GetApplicableRefactorsRequestArgs extends FileLocationOrRangeRequestArgs {\r\n // better name?\r\n returnInvalidRefactorings?: boolean;\r\n}\r\n```\r\n\r\nIf `returnInvalidRefactorings` is not set, the TS Server should preserve its existing behavior, i.e. drop invalid refactorings\r\n\r\n","author":{"url":"https://github.com/mjbvz","@type":"Person","name":"mjbvz"},"datePublished":"2019-11-14T07:48:35Z","url":"https://github.com/microsoft/TypeScript/issues/35098"}
| 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:6d6e39a4-3166-b394-5d6b-419ade8c9e80 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 9DA4:7A60E:96842B:C46245:6B00E1C8 |
| html-safe-nonce | 3f35f1b41f83994253199ce14b040afc734c72f0c0d2592a0920ab98a821c558 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5REE0OjdBNjBFOjk2ODQyQjpDNDYyNDU6NkIwMEUxQzgiLCJ2aXNpdG9yX2lkIjoiNDYxMzA2MTE3NDI2MTUwNjUwNCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 51906fdeb55c329f98315aaa03bb1779c3aa6d332d7653d3e0bb27820898dc10 |
| hovercard-subject-tag | issue:522683482 |
| 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/35098/issue_layout |
| twitter:image | https://opengraph.githubassets.com/5cbb936b539b4588bd95e27d4b3434bee04282211cd6f475ccd2c8f572c1b0f6/microsoft/TypeScript/issues/35098 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/5cbb936b539b4588bd95e27d4b3434bee04282211cd6f475ccd2c8f572c1b0f6/microsoft/TypeScript/issues/35098 |
| og:image:alt | Follow up on #34930 Search terms refactor / refactoring Problem In VS Code, I often try to extract something to a function only to discover that this is not possible for the my current selection. T... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | mjbvz |
| hostname | github.com |
| expected-hostname | github.com |
| None | 043c3f30fbcbe2c6c8e729e10cbbbc90c406546f9fbbb67c648d38f6b7d16daf |
| 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 | 5425dc24e8bd8d6fca9641a12afc984825a43875 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width