microsoft / microsoft/TypeScript

Show deprecated strikethrough for JSX properties when union type

Offen
#57,584 3 Kommentare 13 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Dieses Issue hat noch niemand übernommen.

Awaiting More Feedback Suggestion
Vorherrschende Sprache
Go
Sterne
111k
Forks
14.4k
Ø Merge
1 T. 19 Std.
Gemergte PRs (30 T.)
117

Beschreibung

🔍 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

Beitragsleitfaden

Beitragsleitfaden öffnen

Erste Schritte

  1. Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
  3. Forke das Repository und arbeite in einem Branch.
  4. Öffne einen Pull Request, der die Issue-Nummer nennt.

Rechercherichtung

Beginnen Sie mit der Durchsicht von issue #50079 und fix #50084, in denen die Durchstreichungsbehandlung für vollständig veraltete JSX-Eigenschaften eingeführt wurde. Verfolgen Sie das bestehende JSX-Verhalten bei veralteten Union-Eigenschaftstypen nach und bestimmen Sie, wie der Editor entscheidet, ob eine Eigenschaft durchgestrichen wird. Als erledigt gilt die Aufgabe, wenn veraltete Union-Werte ein entsprechendes visuelles Durchstreichungsverhalten zeigen, während nicht veraltete Werte dies nicht tun.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
typescript
Bereich
tooling
Issue-Typ
Feature
Schwierigkeit
4/5
Geschätzter Aufwand
3-5 Tage
Aktivitätsstatus
Veraltet
Klarheit
Größtenteils klar
Anfängerfreundlichkeit
35/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.