microsoft / microsoft/TypeScript
Auto fixable quick fixes
Nessuno ha ancora preso questa issue.
- Lingua principale
- Go
- Stelle
- 111k
- Fork
- 14.3k
- Merge medio
- 1g 19h
- PR unite (30g)
- 117
Descrizione
VS Code is investigating the concept of autofixable quick fixes. You can find the current proposal here
Motivating use case
You open the following TS file:
interface IFoo {
bar(): void;
}
class Foo implements IFoo { }
new foo()
This file has two errors: incorrect interface implementation on class Foo and a spelling error in new foo()
You hit F8 to start navigating through errors. While navigating, you can hit a single keyboard shortcut to auto implement the interface or to correct foo -> Foo
Current VS Code proposal
To implement auto fixes, VS Code currently proposes that some quick fixes be marked with a canAutoApply flag. This flag would indicate that:
- The quick fix will fix the underlying problem (and not suppress it or hide it)
- The quick fix can be fairly safely automatically applied without user input
- The provider of the quick fix is relatively confident that the quick fix could be correct (100% confidence is not required since the auto fix is being triggered by a user action). More importantly, the quick fix should be easy to undo if it is incorrect
When the user hits auto fix in VS Code, if only a single canAutoApply quick fix is returned for a diagnostic, VS Code would automatically apply it. If multiple canAutoApply fixes are returned, we would show a list of these for the user to select from. The existing, more complete list of quick fixes and code actions could still be accessed using the lightbulb menu
Proposal for TS
The UX experience of being able to auto fix errors with a single keyboard shortcut is very nice and I think we can make reasonable fix assumptions about a fair number of real world errors. The work that would be required on the TS side to support the proposed auto fix feature in VS Code:
- Add an optional
canAutoApplyproperty on the TSCodeFixobjects - Add some logic to decide when a fix can be marked as
canAutoApply.//@ts-ignorefixes for example should never be marked ascanAutoApplybut spelling errors, add missingthis, and perhaps evenadd missing importcould be.
The initial implementation would only need to support canAutoApply for a small set of diagnostics, which could be expanded in future releases.
/cc @DanielRosenwasser, @minestarks, @amcasey
Guida per i contributori
Apri la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Direzione di ricerca
L’issue non indica file o test specifici; identifica gli oggetti CodeFix di TypeScript e la gestione della diagnostica come punti di ingresso rilevanti. Inizia individuando queste aree e revisionando la proposta collegata di VS Code. Il lavoro è completato quando vengono aggiunte la proprietà opzionale canAutoApply e la logica iniziale per alcuni fix sicuri, escludendo i fix ts-ignore.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- typescript
- Ambito
- compilers
- Tipo di issue
- Funzionalità
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Stato di attività
- Ferma
- Chiarezza
- Abbastanza chiara
- Idoneità per principianti
- 35/100