导出默认界面

时间:2018-11-22 14:44:28

标签: node.js reactjs typescript types interface

有一个代码块(./Component/index.ts):

import Component from './blabla';
import { editClassFunc } from '../utils/editClass';
export default editClassFunc(Component);

组件(./Component/blabla.ts):

import React from 'react';

class Component extends React.Component<{
  position?: 'fixed' | 'absolute' | 'sticky' | 'static' | 'relative';
}> {
   ....
}

export default Component;

editClassFunc(./utils/editClass.ts):

export default editClassFunc(Component){
    const EditComponent = Component;
    ...
    return EditComponent
}

与打字稿(./page/index.ts)一起使用:

import Component from '../Component';

export default class Page extends Component<{}> {
  public render() {
    return (
       <Component position="mistake"/>
    );
  }
}

我该怎么做才能使用真正的Component接口, 在./page/index.ts

中错误输入组件属性时,我不会出现错误

0 个答案:

没有答案