Title: Extend createMethodSignature and updateMethodSignature with 'modifiers' argument · Issue #35959 · microsoft/TypeScript · GitHub
Open Graph Title: Extend createMethodSignature and updateMethodSignature with 'modifiers' argument · Issue #35959 · microsoft/TypeScript
X Title: Extend createMethodSignature and updateMethodSignature with 'modifiers' argument · Issue #35959 · microsoft/TypeScript
Description: Search Terms updateMethodSignature, createMethodSignature Suggestion It should be possible to provide an array of Modifiers (or undefined) to the createMethodSignature and updateMethodSignature functions. Use Cases When using the TypeScr...
Open Graph Description: Search Terms updateMethodSignature, createMethodSignature Suggestion It should be possible to provide an array of Modifiers (or undefined) to the createMethodSignature and updateMethodSignature fun...
X Description: Search Terms updateMethodSignature, createMethodSignature Suggestion It should be possible to provide an array of Modifiers (or undefined) to the createMethodSignature and updateMethodSignature fun...
Opengraph URL: https://github.com/microsoft/TypeScript/issues/35959
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Extend createMethodSignature and updateMethodSignature with 'modifiers' argument","articleBody":"## Search Terms\r\n\r\n\u003c!-- List of keywords you searched for before creating this issue. Write them down here so that others can find this suggestion more easily -->\r\nupdateMethodSignature, createMethodSignature\r\n\r\n## Suggestion\r\n\r\n\u003c!-- A summary of what you'd like to see added or changed -->\r\nIt should be possible to provide an array of Modifiers (or `undefined`) to the `createMethodSignature` and `updateMethodSignature` functions.\r\n\r\n## Use Cases\r\n\r\n\u003c!--\r\nWhat do you want to use this for?\r\nWhat shortcomings exist with current approaches?\r\n-->\r\n\r\nWhen using the TypeScript compiler APIs, TypeScript provides numerous `create` and `update` functions that can be used to generate an AST, for example from Custom Transformers. However, for `MethodSignature`s, which may have modifiers such as the `static` keyword, there's no option to create or update their modifiers. This breaks [one of my libraries](https://github.com/wessberg/ts-clone-node) which sole purpose is to simply deep-clone a TypeScript node. A workaround is to manually patch the modifiers, however I hope this can be part of the function (as it is for others, like `createPropertySignature` and `updatePropertySignature`).\r\n\r\n## Examples\r\n\r\n\u003c!-- Show how this would be used and what the behavior would be -->\r\n\r\n```typescript\r\nimport {createMethodSignature, createNodeArray, createModifier, SyntaxKind} from \"typescript\";\r\n\r\ncreateMethodSignature(\r\n createNodeArray([\r\n createModifier(SyntaxKind.StaticKeyword)\r\n ]),\r\n node.typeParameters,\r\n node.parameters,\r\n node.type,\r\n node.name,\r\n node.questionToken\r\n);\r\n```\r\n\r\nHowever, the above example would be a breaking change since the first parameter expects a NodeArray of type parameters, so an alternative solution would be to accept it as the last argument.\r\n\r\n## Checklist\r\n\r\nMy suggestion meets these guidelines:\r\n\r\n* [X] This wouldn't be a breaking change in existing TypeScript/JavaScript code\r\n* [X] This wouldn't change the runtime behavior of existing JavaScript code\r\n* [X] This could be implemented without emitting different JS based on the types of the expressions\r\n* [X] This isn't a runtime feature (e.g. library functionality, non-ECMAScript syntax with JavaScript output, etc.)\r\n* [X] This feature would agree with the rest of [TypeScript's Design Goals](https://github.com/Microsoft/TypeScript/wiki/TypeScript-Design-Goals).\r\n","author":{"url":"https://github.com/wessberg","@type":"Person","name":"wessberg"},"datePublished":"2020-01-02T12:12:36Z","url":"https://github.com/microsoft/TypeScript/issues/35959"}
| 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:5a337dab-ed82-75cf-b998-fcea3e224902 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | BCBE:38C5CF:75D001:99D85E:6B00D46B |
| html-safe-nonce | a24ec9a4c6227859b8b8732f9a344365eb6bdb93e3dd43cc35ee2889b210f701 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCQ0JFOjM4QzVDRjo3NUQwMDE6OTlEODVFOjZCMDBENDZCIiwidmlzaXRvcl9pZCI6IjEyNzkwMDUwMzQ0OTQ4NzQ3MzEiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 06ba24838ea93ee773e66e89cf2b169d4f8eb5263f921a2460c978663fdd3f67 |
| hovercard-subject-tag | issue:544555173 |
| 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/35959/issue_layout |
| twitter:image | https://opengraph.githubassets.com/922164fc1e28684354fb5351308c6780fc6b24c7345997ff05758fd5803ee280/microsoft/TypeScript/issues/35959 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/922164fc1e28684354fb5351308c6780fc6b24c7345997ff05758fd5803ee280/microsoft/TypeScript/issues/35959 |
| og:image:alt | Search Terms updateMethodSignature, createMethodSignature Suggestion It should be possible to provide an array of Modifiers (or undefined) to the createMethodSignature and updateMethodSignature fun... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | wessberg |
| hostname | github.com |
| expected-hostname | github.com |
| None | 85bbdfe2b6ba16e234513bc6ceff5d848ef8449820c900692a2b4e67061931e5 |
| 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 | 4943239a6d2c591325dad6e5c313e1cafda877f6 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width