import {
  EIssueType,
  EIssueConsequence
} from '../../enum';
import {
  IFixing
} from '../../types';

export const FIXING_PROP_CONTAINER: IFixing = {
  propName: 'container',
  codeOld: `interface AffixProps {
  container?: () => React.ReactElement<any>;
}`,
  codeNew: `interface AffixProps {
  container?(): void | null | undefined | Window | HTMLElement;
}`,
  issues: [{
    title: '返回 <code>ReactElement</code> 导致 JS 错误',
    code: '<Affix container={() => refReactElement} />',
    type: EIssueType.RUNTIME_WARNING,
    error: 'Uncaught TypeError: node.getBoundingClientRect is not a function',
    consequences: [EIssueConsequence.UNCAUGHT]
  }, {
    title: '返回 <code>window</code> 无法匹配 <code>ReactElement</code>',
    code: '<Affix container={() => window} />',
    type: EIssueType.TYPE_FALSE_REPORT,
    consequences: [EIssueConsequence.BUILD_FAIL]
  }, {
    title: '返回 <code>null</code> 无法匹配 <code>ReactElement</code>',
    code: '<Affix container={() => null} />',
    type: EIssueType.TYPE_FALSE_REPORT,
    consequences: [EIssueConsequence.BUILD_FAIL]
  }]
};
