如何使用不同的tsconfig文件进行测试? [英] How to use different tsconfig file for tests?

查看:261
本文介绍了如何使用不同的tsconfig文件进行测试?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的项目中,我使用了2个不同的tsconfig文件

in my project I use 2 different tsconfig files

  • tsconfig.json
  • tsconfig.specs.json-用于测试
  • tsconfig.json
  • tsconfig.specs.json - for testing

如何告诉Intellij Idea两者同时使用?
即在Settings-Langauges & Frameworks-TypeScript中,我可以在不同的Compile scope之间进行切换,但是Options并不是每个编译范围(每个项目只能一个).

how can I tell Intellij Idea to use both?
i.e. In Settings - Langauges & Frameworks - TypeScript I can switch between different Compile scopes, but the Options are not per compile scope (but only once per project).

注意:

  • I use IntelliJ IDEA Ultimate 18.2.5
  • I found a related issue WEB-15538: TypeScript WebStorm 10 EAP: Scope & by module configuration- but maybe this was only fixed for WebStorm - not in Idea Ultimate?

推荐答案

我认为我们只需要注册文件类型:

I think we only need to register the file-types:

设置中| 编辑器 | 文件类型> TypeScript Config 添加您的自定义tsconfig文件名,例如

In Settings | Editor | File Types > TypeScript Config add your custom tsconfig file names, e.g.

  • tsconfig.app.json
  • tsconfig.lib.json
  • tsconfig.spec.json
  • tsconfig.app.json
  • tsconfig.lib.json
  • tsconfig.spec.json
  • etc.

有了这些设置:

  • IntelliJ应该在tsconfig文件中显示语法高亮和完成建议
  • IntelliJ打字稿服务应识别所有这些tsconfig文件并编译所有内容:
    也就是说,重要的是,您必须在每个文件中使用包含/排除 tsconfig文件,以便仅编译相关文件
  • IntelliJ should show syntax highlighting and completion suggestions in your tsconfig files
  • the IntelliJ typescript service should recognize all these tsconfig files and compile everything:
    i.e. it is important that you use include/exclude in each of the tsconfig files, so that only the relevant files are compiled

这篇关于如何使用不同的tsconfig文件进行测试?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆