引入 @vue/tsconfig,更改了 tsconfig.json 的结构 #3955
Closed
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.
这个提交是在 #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 加上了。