microsoft / microsoft/TypeScript
Show deprecated strikethrough for JSX properties when union type
Personne n'a encore pris cette issue.
- Langage dominant
- Go
- Étoiles
- 111k
- Forks
- 14.4k
- Merge moyen
- 1 j 19 h
- PR mergées (30 j)
- 117
Description
🔍 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
- 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, new syntax sugar for JS, etc.)
- This isn't a request to add a new utility type: https://github.com/microsoft/TypeScript/wiki/No-New-Utility-Types
- This feature would agree with the rest of our Design Goals: https://github.com/Microsoft/TypeScript/wiki/TypeScript-Design-Goals
⭐ 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
- 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
Guide de contribution
Ouvrir le guide de contribution
Par où commencer
- Lisez l'issue en entier, puis le guide de contribution du projet.
- Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
- Forkez le dépôt et travaillez sur une branche.
- Ouvrez une pull request qui référence le numéro de l'issue.
Piste de recherche
Commencez par examiner issue #50079 et fix #50084, qui ont établi la gestion du texte barré pour les propriétés JSX entièrement obsolètes. Suivez le comportement existant de dépréciation de JSX pour les types de propriétés d’union et déterminez comment l’éditeur décide de barrer ou non une propriété. Le travail est terminé lorsque les valeurs d’union obsolètes produisent un comportement visuel de texte barré correspondant, tandis que les valeurs non obsolètes ne le font pas.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Évaluation
- Stack technique
- typescript
- Domaine
- tooling
- Type d'issue
- Fonctionnalité
- Difficulté
- 4/5
- Temps estimé
- 3-5 jours
- Activité
- À l'abandon
- Clarté
- Plutôt claire
- Accessibilité débutants
- 35/100