microsoft / microsoft/TypeScript

Extend createMethodSignature and updateMethodSignature with 'modifiers' argument

Abierto
#35,959 1 comentario 0 reacciones 0 asignados Ver en GitHub

Nadie ha tomado este issue todavía.

Domain: API In Discussion Suggestion
Lenguaje dominante
Go
Estrellas
111k
Forks
14.3k
Merge medio
2 d 4 h
PR fusionados (30 d)
132

Descripción

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.

Guía de contribución

Abrir la guía de contribución

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Línea de trabajo

Comienza inspeccionando las definiciones y las implementaciones de la TypeScript Compiler API de createMethodSignature y updateMethodSignature, comparándolas con createPropertySignature y updatePropertySignature. Determina un diseño no disruptivo para el argumento modifiers y verifica después que las llamadas existentes sigan siendo válidas y que las firmas de método puedan crearse o actualizarse con modifiers.

Escrito por el modelo de indexación a partir del texto del issue.

Evaluación

Stack tecnológico
typescript
Área
compilers
Tipo de issue
Nueva funcionalidad
Dificultad
3/5
Tiempo estimado
1-2 días
Estado de actividad
Estancado
Claridad
Bastante claro
Aptitud para principiantes
35/100

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.