microsoft / microsoft/TypeScript
Extend createMethodSignature and updateMethodSignature with 'modifiers' argument
Personne n'a encore pris cette issue.
- Langage dominant
- Go
- Étoiles
- 111k
- Forks
- 14.4k
- Merge moyen
- 1 j 19 h
- PR mergées (30 j)
- 117
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 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.
Guide de contribution
Ouvrir le guide de contribution
Par où commencer
- Lisez l'issue en entier, puis le guide de contribution du projet.
- Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
- Forkez le dépôt et travaillez sur une branche.
- Ouvrez une pull request qui référence le numéro de l'issue.
Piste de recherche
Commencez par examiner les définitions et les implémentations de la TypeScript Compiler API de createMethodSignature et updateMethodSignature, en les comparant à createPropertySignature et updatePropertySignature. Déterminez une conception non rétrocompatible de l’argument modifiers, puis vérifiez que les appels existants restent valides et que les signatures de méthode peuvent être créées ou mises à jour avec modifiers.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Évaluation
- Stack technique
- typescript
- Domaine
- compilers
- Type d'issue
- Fonctionnalité
- Difficulté
- 3/5
- Temps estimé
- 1-2 jours
- Activité
- À l'abandon
- Clarté
- Plutôt claire
- Accessibilité débutants
- 35/100