首页 > 解决方案 > 生成的 .d.ts 文件未正确获取导入

问题描述

我的default.ts档案

import { Type, Units } from './Duration.types';
const defaultDuration = {
  type: Type.Dynamic,
  range: {
    count: 12,
    unit: Units.Hours
  }
};
export { defaultDuration }

Type并且Unitsenum并且被导出为export { Type, Units }

这是我使用它的组件。 Component.tsx

import { defaultDuration } from './defaults';    
static defaultProps = {
  allowToggle: true,
  duration: defaultDuration
};

我做npm run build了并得到了一个显示错误的生成Component.d.ts文件。

static defaultProps: {
        allowToggle: boolean;
        duration: {
            type: Type;
            range: {
                count: number;
                unit: Units;
            };
        };
    };

错误说它找不到TypeUnits.d.ts文件中

当我尝试.d.ts在其他地方导入此文件时,它会引发上述错误。

标签: javascripttypescriptecmascript-6typescript-typings

解决方案


推荐阅读