0 v5 API 废弃流程
Amumu edited this page 2022-08-17 17:53:34 +08:00
This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

废弃警告

基于 feature 开启新的 branch。

TS 废弃提示

interface SampleProps {
  // ...
  /** @deprecated `propOld` is deprecated which will be removed in next major version. Please use `propNew` instead. */
  propOld?: string;
  propNew?: string;
}

console 废弃提示与兼容

const Sample = (props) => {
  const { propOld, propNew, ...restProps } = props;

  warning(!propOld, 'Sample', '`propOld` is deprecated which will be removed in next major version. Please use `propNew` instead.');

  return <Component prop={propNew ?? propOld} {...restProps} />;
}

补充对应 test case

it('deprecated warning', () => {
  const errSpy = jest.spyOn(console, 'error').mockImplementation(() => {});

  render(<Sample propOld="xxx" />);

  expect(errSpy).toHaveBeenCalledWith('xxxxxxxx');

  errSpy.mockRestore();
});

🚨🚨🚨 注意:不要删除或者修改原本的测试用例,总是新增测试用例以防止改动 Break 原本用法 🚨🚨🚨

文档更新

在 Demo 的 markdown 文件中搜索对应 prop将其替换为最新 prop。

在组件文档中,搜索对应 prop 将其替换为最新 prop🔥🔥🔥 并添加下一个 minor 版本版本号 🔥🔥🔥

发起 PR

feature branch 发起 PR。

V5 版本移除

上述 PR 合并后,在 next branch 中,开新的 PR 移除该接口并且在 v5-note.md 中记录变更:

Sample 组件 dropdownClassName 替换为 popupClassName

兼容包

兼容组件

https://github.com/ant-design/compatible 中,参考 AutoComplete 添加对应 TS 定义 以及 warning 信息。

导出组件

src/index.tsx 中导出组件:

export { default as Select } from './SelectBase';
export { default as AutoComplete } from './AutoComplete';

添加测试

参考 AutoComplete 添加对应测试用例。