microsoft / microsoft/TypeScript
Extend createMethodSignature and updateMethodSignature with 'modifiers' argument
まだ誰も着手していません。
- 主要言語
- Go
- スター
- 111k
- フォーク
- 14.4k
- 平均マージ
- 1日 19時間
- マージ済み PR(30日)
- 117
説明
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 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 MethodSignatures, 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 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).
Examples
import {createMethodSignature, createNodeArray, createModifier, SyntaxKind} from "typescript";
createMethodSignature(
createNodeArray([
createModifier(SyntaxKind.StaticKeyword)
]),
node.typeParameters,
node.parameters,
node.type,
node.name,
node.questionToken
);
However, 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.
Checklist
My suggestion meets these guidelines:
- This wouldn't be a breaking change in existing TypeScript/JavaScript code
- This wouldn't change the runtime behavior of existing JavaScript code
- This could be implemented without emitting different JS based on the types of the expressions
- This isn't a runtime feature (e.g. library functionality, non-ECMAScript syntax with JavaScript output, etc.)
- This feature would agree with the rest of TypeScript's Design Goals.
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
まず、TypeScript Compiler API における createMethodSignature と updateMethodSignature の定義および実装を調べ、createPropertySignature と updatePropertySignature と比較します。破壊的変更にならない modifiers 引数の設計を決定し、その後、既存の呼び出しが引き続き有効であり、modifiers を指定してメソッドシグネチャを作成または更新できることを検証します。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- typescript
- 領域
- compilers
- issue の種類
- 機能追加
- 難易度
- 3/5
- 見積もり時間
- 1〜2日
- 活発さ
- 停滞
- 明瞭さ
- おおむね明確
- 初心者へのやさしさ
- 35/100