Automated Migration for Breaking Changes to the Type System

Aberta
#33,345 7 comentários 11 reações 0 responsáveis Ver no GitHub

Ninguém assumiu esta issue ainda.

Avaliação

Dificuldade
5/5
Tempo estimado
Mais de uma semana
Facilidade para iniciantes
20/100
Tipo de issue
Funcionalidade
Clareza
Precisa de esclarecimento
Status de atividade
Estagnada
Stack de tecnologia
typescript
Domínio
compilers

Direção de pesquisa

Comece lendo as breaking changes descritas em TypeScript issue 33272 e analisando a TypeScript Compiler API como base proposta para codemods. Defina quais migrações somente de tipos podem ser automatizadas, como a ferramenta relata os casos que introduziriam erros e como os usuários a invocam. O trabalho estará concluído quando houver um design de migração com escopo definido e uma separação clara entre transformações automatizadas e decisões humanas.

Escrita pelo modelo de indexação a partir do texto da issue.

Descrição

Needs Proposal Suggestion

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.
Linguagem predominante
Go
Estrelas
111k
Forks
14.4k
Merge médio
1d 19h
PRs com merge (30d)
117

Guia de contribuição

Abrir o guia de contribuição

Primeiros passos

  1. Leia a issue inteira e depois o guia de contribuição do projeto.
  2. Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
  3. Faça um fork do repositório e trabalhe em uma branch.
  4. Abra um pull request que referencie o número da issue.

Mais de microsoft/TypeScript

Todas as issues de microsoft/TypeScript

Issues semelhantes

Mais issues de Go

Receba novas issues na sua caixa de entrada

Um resumo curto de issues do GitHub para quem está começando.