Closed canisminor1990 closed 12 months ago
非 .dumi
下的类型应该的确是存在错误的,之前不报错是 bug,参考:https://github.com/umijs/father/pull/701
.dumi
下的类型错误我复现看下
"typescript": "^5.2.2", Father build Generate declaration files 也有问题
father@4.3.1正常,father@4.3.3有问题
tsconfig.json
的 include
配置项中的 .dumi/**/*
可以去掉,dumi 提供的模板有问题,框架临时文件不应该被 include
两种建议的修改方式:
.dumi
下有本地主题、运行时插件等非临时文件,那么在 exclude 中新增 .dumi/{tmp,tmp-*}
或者把 include 改成 .dumi/theme
.dumi
下只有临时文件,那么去掉 .dumi/**/*
即可dumi 下个版本会更新 warning 和脚手架,并增加 tsconfig 自动修正逻辑
v4.3.4 修复了该问题,方案是过滤掉不属于 father 编译源文件产生的类型错误,可以更新到新版试试看
@PeachScript :v4.3.4下, 编译错误
error - src/foo2/index.tsx:8:7 - TS2742: The inferred type of 'Foo2' cannot be named without a reference to 'packages/demo2/node_modules/@types/react/ts5.0/jsx-runtime'. This is likely not portable. A type annotation is necessary.
error - src/foo2/index.tsx:8:7 - TS2742: The inferred type of 'Foo2' cannot be named without a reference to 'packages/demo2/node_modules/@types/react/ts5.0/jsx-runtime'. This is likely not portable. A type annotation is necessary.
error - Error: Declaration generation failed.
编译错误代码
type IFoo2Props = {
/**
* @description 标题
* @default "默认值"
*/
title: string;
};
const Foo2 = (props: IFoo2Props) => <h4>{props.title}</h4>;
export default Foo2;
这样就编译正常
import type { FC } from 'react';
type IFoo2Props = {
/**
* @description 标题
* @default "默认值"
*/
title: string;
};
const Foo2: FC<IFoo2Props> = (props) => <h4>{props.title}</h4>;
export default Foo2;
后面的问题,移步到 #713
Father build Generate declaration files 在
4.3.2
和4.3.3
报错,4.3.1
中正常https://github.com/lobehub/lobe-ui/actions/runs/6108436253/job/16583229714