Open codepb opened 7 months ago
In this case the strikethrough should probably go on the value, since putting it on the property name implies the property itself is deprecated (which suggests the current behavior might have been intentional)
I have the exact same use-case. One of the values in a type union needs to be deprecated, the @deprecated
appears on hover, but there is no strikethrough on the UI.
export type ValidOptions = 'none' | 'global';
type DeprecatedOptions = 'all';
export type Option =
| {
/**
* @deprecated Use 'global' instead.
*/
a: DeprecatedOptions;
b?: ValidOptions;
}
| {
a?: ValidOptions;
/**
* @deprecated Use 'global' instead.
*/
b: DeprecatedOptions;
}
| {
/**
* @deprecated Use 'global' instead.
*/
a: DeprecatedOptions;
/**
* @deprecated Use 'global' instead.
*/
b: DeprecatedOptions;
}
| {
a?: ValidOptions;
b?: ValidOptions;
};
We would like to deprecate some values before removing them from public APIs. This would make the deprecation clearer to the user before we actually remove the values in a later version.
🔍 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:
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
and I'm transitioning the new type to be:
and would like to support both types in the interim, but notify uses explicitly to use the new values.