Skip to content
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

引入 @vue/tsconfig,更改了 tsconfig.json 的结构 #3955

Closed
wants to merge 6 commits into from

Conversation

timongh
Copy link
Contributor

@timongh timongh commented Jan 29, 2023

这个提交是在 #3952 的基础上修改的。

一个主要更改是让 tsconfig 继承了 @vue/tsconfig 这个包。并修复其带来的新的类型错误。

另外我还改了下各目录之间 tsconfig 的结构。不过这个提交是独立的,如果不接受的话我可以把这个提交去掉再重新提上来。这么改的主要原因是 node 环境和 web 环境总归是不同,用同一个 tsconfig(对 IDE 来说)在一些小地方用着不顺心。

一个例子是:setTimeout 类型总是被 IDE 识别成 Node 的里的类型,导致返回值不兼容。

这次更改的主要操作是:把 node 的 tsconfig 单独抽离成了 tsconfig.node.json,再在各个需要使用 node 环境的文件夹里新建 tsconfig.json 来继承这个文件。这么做就能够让 IDE 分清楚各个文件使用的是哪个环境了。更改方式主要参考webpack 官方文档中的第三种方法

另外,因为引入了 tsconfig-paths 包,所以现在可以在 node 环境的代码里用绝对路径和路径映射了。

还有一点:无论是 ts-node 还是 webpack 都有独立的产出配置,因此 tsc 的生成产物是完全不需要的,所以我就直接在 tsconfig 里把 noEmit 加上了。

@timongh
Copy link
Contributor Author

timongh commented Jan 30, 2023

好吧,我发现改了 tsconfig.json 的结构,setTimeout 还是会被识别成 Node 里面的函数。有点懵,我再看看有没有法子(我指的不是用 window.setTimeout 这种)

@timongh
Copy link
Contributor Author

timongh commented Jan 30, 2023

我还是拆出来吧

@timongh timongh closed this Jan 30, 2023
@timongh timongh deleted the change-tsconfig branch January 30, 2023 11:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant