microsoft / microsoft/TypeScript

Provide way to configure default compiler options for TS Server Inferred Project

未关闭
#39,689 3 条评论 8 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

In Discussion Suggestion
主要语言
Go
星标
111k
派生
14.3k
平均合并
2 天 4 小时
30 天内合并 PR
132

描述

Search Terms

Inferred Project
TS Server

Suggestion

Add an option to configure the default compilerOptions for inferred projects outside of the host.

Related to: https://docs.google.com/document/d/1eB6cGCG_2ircfS5GzpDC9dBgikeYYcMxghVH5sDESHw/edit#heading=h.telvo0tzo7t0 and https://github.com/microsoft/TypeScript/issues/39632

Checklist

Use Cases

Currently, there is no way to configure the default compilerOptions for inferred projects outside of the server host. Being able to configure should options would be give a better DX when not using the default compiler options such as experimentalDecorators, strictNullChecks etc... together with stricter file inclusions, ie favoring explicitly listing the entry-point files using files instead of include with globbing.

Previously when not using TypeScript solution style tsconfig this could be achieved by adding a tsconfig.json in the root of the project which will include all files and set these options example.

{
   "compilerOptions":  {
     "experimentalDecorators": true,
     "strictNullChecks": true,
     ...
   }
}

This trickery cannot be used when using a solution style tsconfig, because the root tsconfig will not contain any files due to files: [] setting.

Examples

Ideally, compiler options for inferred projects are configured in a TypeScript configuration file. When using solution style tsconfig, such configuration can be set here.

{
 "files": [],
 "compilerOptions":  {
   "experimentalDecorators": true,
   "strictNullChecks": true,
   ...
 },
 "references": [
   {
     "path": "./tsconfig.app.json"
   },
   {
     "path": "./tsconfig.spec.json"
   }
 ]
}

My suggestion meets these guidelines:

  • This wouldn't be a breaking change in existing TypeScript/JavaScript code
  • This wouldn't change the runtime behavior of existing JavaScript code
  • This could be implemented without emitting different JS based on the types of the expressions
  • This isn't a runtime feature (e.g. library functionality, non-ECMAScript syntax with JavaScript output, etc.)
  • This feature would agree with the rest of TypeScript's Design Goals.

//cc @kyliau

贡献指南

打开贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

调研方向

先从 TS Server 的 inferred projects 行为和关联的 issue 39632 入手,然后检查如何处理包含 files: [] 的 solution-style tsconfig 文件。确定为 compilerOptions 中的 experimentalDecorators 和 strictNullChecks 等默认值所需的配置位置和优先级。完成标准是 inferred projects 可以获得这些默认值,同时不改变现有项目的行为。

由索引模型根据 Issue 内容生成。

评估

技术栈
typescript
领域
tooling
Issue 类型
功能
难度
5/5
预计耗时
一周以上
活跃度
停滞
描述清晰度
基本清楚
新手友好度
35/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。