New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: correct defineConfig parameter typing #1389
Merged
PeachScript
merged 2 commits into
umijs:master
from
tinymins:fix-dumi-config-interface-typing
Dec 26, 2022
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
用
ReturnType
更简单点?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这个有解的,在
npm publish
之前用tsc-alias -p tsconfig.json
处理一下就好了,原理就是在最后发布给用户之前去掉所有的 alias (将其替换为相对目录)。There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
诶不是,等会,
@@/*
不是必定在tsconfig
/alias
里面嘛, dumi 的教程里头有来着, https://d.umijs.org/guide/upgrading#%E6%9B%B4%E6%96%B0-tsconfigjsonThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
换引入路径的方法可能不行,主要 Umi 项目的
@@
指向位置不确定,加上umi/dist/types.d.ts
也不能直接从../../../.dumi/tmp
里引入,这样 monorepo 提升依赖的场景可能就挂了There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
题外话,顺便推荐下 father,编译时会根据 tsconfig.json 自动处理 paths 替换为相对路径,底层是基于 tsconfig-paths,以后有类似构建需求可以试试看😁
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
认同这个观点;defineConfig 不会被框架内部调用,它的返回值即配置文件
.dumirc.ts
最终的导出结果,也就是用户的声明值,框架内部会消费配置文件的导出结果There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
那看来绕不过了,我改下模板
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
站在用户使用的角度来看,
.dumi.ts
中的config
对象是 即将传递给 dumi 和 umi 的 config 的联合体,从这个角度来说,就应该是Parameters<dumi.defineConfig>[0] & Parameters<umi.defineConfig>[0]
,也是我最开始修改的思路。但是站在
dumi
内部来看,这个config
并没有直接传给umi
的defineConfig
,也确实不应该是Parameters
。所以是否应该改成
ReturnType
我有点疑惑了。 😂There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
保持现状吧不纠结,dumi 的
defineConfig
入参继承自 Umi 的defineConfig
入参,也说得通 👀There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Re: 题外话,已经升级至 v4 并且移除了 tsc-alias 依赖,非常好用~ 😸