microsoft / microsoft/TypeScript

Show deprecated strikethrough for JSX properties when union type

Aperta
#57,584 3 commenti 13 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Awaiting More Feedback Suggestion
Lingua principale
Go
Stelle
111k
Fork
14.4k
Merge medio
1g 19h
PR unite (30g)
117

Descrizione

🔍 Search Terms

"strikethrough deprecated prop jsx", "strikethrough deprecated prop react", "strikethrough deprecated property jsx", "strikethrough deprecated property react", "deprecated property react", "deprecated property jsx"

✅ Viability Checklist
⭐ Suggestion

I came across #50079 and the fix #50084 which works nicely when the whole property is deprecated. However it's also possible to create a type like the following:

{
  myProp: 'a' | 'b' | 'c'
} | { 
  /** @deprecated use 'a' | 'b' | 'c' */
  myProp: 1 | 2 | 3
}

This still correctly shows the deprecated message when hovered over the property in JSX when the value of the property is 1, 2, or 3, and not when the value is 'a', 'b' or 'c'. However the property is never shown with a strikethrough. It would be fantastic if the strikethrough on the property could match the deprecated message behaviour in the hover pop over.

📃 Motivating Example

TypeScript has now extended deprecation checking in JSX to visually add a strikethrough to a property when the property is still valid, but a deprecated value for the property is used (see example in the suggestion above).

💻 Use Cases
  1. What do you want to use this for?
    When transitioning a React component's property to a new set of values it would be useful to maintain the old values for backwards compatibility but deprecate them to visually indicate to a user that they should no longer be using them. My specific use case is when the original values were less explicit:
size: 'classname-small' | 'classname-medium' | 'classname-large'

and I'm transitioning the new type to be:

size: 's' | 'm' | 'l'

and would like to support both types in the interim, but notify uses explicitly to use the new values.
2. What shortcomings exist with current approaches?
There is no visual indication that the value is deprecated without hovering over the property
3. What workarounds are you using in the meantime?
It's not possible to workaround. Just have to deal with it only being in the pop up

Guida per i contributori

Apri la guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Direzione di ricerca

Inizia esaminando issue #50079 e fix #50084, che hanno stabilito la gestione del testo barrato per le proprietà JSX completamente obsolete. Analizza il comportamento esistente di deprecazione di JSX per i tipi di proprietà union e determina come l’editor decide se barrare una proprietà. Il lavoro è completato quando i valori union deprecati producono un comportamento visivo di testo barrato corrispondente, mentre i valori non deprecati non lo producono.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
typescript
Ambito
tooling
Tipo di issue
Funzionalità
Difficoltà
4/5
Tempo stimato
3-5 giorni
Stato di attività
Ferma
Chiarezza
Abbastanza chiara
Idoneità per principianti
35/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.