بنقرة واحدة
deprecate-react-component
Take an existing React component and add a deprecated/new overload pattern to it
التثبيت باستخدام Codex أو Claude انسخ هذا Prompt والصقه في Codex أو Claude أو مساعد آخر ليراجع صفحة Skill ويثبّتها لك.
القائمة
Take an existing React component and add a deprecated/new overload pattern to it
التثبيت باستخدام Codex أو Claude انسخ هذا Prompt والصقه في Codex أو Claude أو مساعد آخر ليراجع صفحة Skill ويثبّتها لك.
استنادا إلى تصنيف SOC المهني
| name | deprecate-react-component |
| description | Take an existing React component and add a deprecated/new overload pattern to it |
| argument-hint | ["ComponentName"] |
Refactor the existing $ARGUMENTS component in packages/components/src/$ARGUMENTS/index.tsx
to support both a deprecated legacy signature and a new versioned signature using TypeScript
function overloads.
Use templates/deprecated-component.tsx as the reference pattern.
New{{ComponentName}}Props interfaceBelow the existing props interface, add:
export interface New{{ComponentName}}Props extends {{ComponentName}}Props {
new: true;
}
Legacy{{ComponentName}}Change const {{ComponentName}} = ... to function Legacy{{ComponentName}}(props: {{ComponentName}}Props): React.JSX.Element.
Keep the body unchanged.
New{{ComponentName}} private functionCopy the Legacy{{ComponentName}} body as the starting point for the new implementation.
Place it directly below Legacy{{ComponentName}}.
{{ComponentName}} functionWrap the three declarations in eslint-disable / eslint-enable no-redeclare comments.
Mark the first overload as @deprecated:
/* eslint-disable no-redeclare */
/** @deprecated Add "new" prop to {{ComponentName}} to get the updated version */
function {{ComponentName}}(props: {{ComponentName}}Props): React.JSX.Element;
function {{ComponentName}}(props: New{{ComponentName}}Props): React.JSX.Element;
function {{ComponentName}}(props: {{ComponentName}}Props | New{{ComponentName}}Props): React.JSX.Element {
if ('new' in props) {
return New{{ComponentName}}(props);
}
return Legacy{{ComponentName}}(props);
}
/* eslint-enable no-redeclare */
export default {{ComponentName}} unchanged{{ComponentName}}Props itself as @deprecated — the deprecation lives only on the overload signature. Marking the interface would cause noise wherever the type is referenced (e.g. inside New{{ComponentName}}Props extends {{ComponentName}}Props).eslint-disable no-redeclare block is required because the project uses ESLint's base no-redeclare rule, which does not understand TypeScript function overloads.new discriminant on New{{ComponentName}}Props is what TypeScript uses to narrow the union in the dispatch function — 'new' in props.