microsoft / microsoft/TypeScript

Automated Migration for Breaking Changes to the Type System

Abierto
#33,345 7 comentarios 11 reacciones 0 asignados Ver en GitHub

Nadie ha tomado este issue todavía.

Needs Proposal Suggestion
Lenguaje dominante
Go
Estrellas
111k
Forks
14.4k
Merge medio
1 d 19 h
PR fusionados (30 d)
117

Descripción

Automated Migration for Breaking Changes to the Type System

Search Terms

codemod, migration, upgrade

Suggestion

semi-automated migration when there are breaking changes in the type system

One way of implementing this would be via codemods (could use the TS Compiler API) that do trivial update tasks as described in https://github.com/microsoft/TypeScript/issues/33272

Use Cases

  • Would make it easier for users to upgrade to the latest TypeScript
  • Would make it easier for the TS team to upgrade TypeScript
  • Might enable TS to evolve faster, as the pain from these "breaking" changes will be smaller

The changes described in https://github.com/microsoft/TypeScript/issues/33272, for example, were mostly trivial, and ideally would not need much human intervention.

Type-only changes are especially amenable to this kind of treatment, because no one's app will misbehave at runtime if there is a bug in the transformation.

I say 'semi-automated' because in cases where the tool can't figure out the problem, the tool could yield to human judgment. Tooling for this doesn't have to be perfect, but a small amount of automation could go a long way.

Examples

example.ts

const myPromise: Promise<{}> = dontCarePromise();

tsc --upgrade --from=3.5 --to=3.6 example.ts

const myPromise: Promise<unknown> = dontCarePromise();

The example is from https://github.com/microsoft/TypeScript/issues/33272.

In a case where the conversion would lead to a new type error, I'd expect the tool to bail out, explain the situation, and let the human decide what to do.

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 leyendo los breaking changes descritos en TypeScript issue 33272 y revisando la TypeScript Compiler API como base propuesta para los codemods. Define qué migraciones que solo afectan a tipos pueden automatizarse, cómo informa la herramienta de los casos que introducirían errores y cómo la invocan los usuarios. Se considera terminado cuando haya un diseño de migración acotado con un límite claro entre las transformaciones automatizadas y las decisiones humanas.

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
5/5
Tiempo estimado
Más de una semana
Estado de actividad
Estancado
Claridad
Necesita aclaración
Aptitud para principiantes
20/100

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.