microsoft / microsoft/TypeScript
Formatting fails for entire file when a line contains only whitespace between two comments
- 主要语言
- Go
- 星标
- 111k
- 派生
- 14.3k
- 平均合并
- 2 天 4 小时
- 30 天内合并 PR
- 132
描述
Per Ryan's suggestion [here](https://github.com/microsoft/TypeScript/issues/63442) I am reposting this. This bug still occurs in typescript-go version 0.20260427.1
### 💻 Code
```ts
const x = "wont format"
//
//
```
- Notice the white space in line 3 between the two comments
- Attempt to format (in VS code by shift + alt + F)
- Notice how line 1 will not indent, this affects the entire file
This bug is difficult to reproduce if you have the "files.trimTrailingWhitespace" option enabled, as it will remove the whitespace in line 3 on save allowing formatting to work again as intended
This affects both TypeScript and JavaScript files
### 🕗 Version & Regression Information
- This changed between versions 4.5.5 and 6.0.3 (incl dev.20260416 nightly) incl (tsgo 0.20260427.1)
- This is the behavior in every version I tried, and I reviewed the FAQ for entries about formatting and indentation
### ⏯ Playground Link
https://www.typescriptlang.org/play/?ts=6.0.3#code/AQYw9gdgzgLsAewC8wBEB3ScBmYBOAtgIYyoBQA9BWcJRUA
### 🙁 Actual behavior
The formatting for the entire file fails silently. No lines are formatted or indented.
### 🙂 Expected behavior
The formatter should indent code correctly (const x in line 1)
### Additional information about the issue
Issue does not affect /* */ only // comments
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
评估
这个 Issue 还没有评估数据。