microsoft / microsoft/TypeScript

Formatting fails for entire file when a line contains only whitespace between two comments

Abierto
#63,816 0 comentarios 2 reacciones 2 asignados Ver en GitHub

@DanielRosenwasser ya está trabajando en esto.

Desde el 27/4/2026.

  • #3630 de @copilot-swe-agent — cerrado sin fusionar
Lenguaje dominante
Go
Estrellas
111k
Forks
14.3k
Merge medio
2 d 4 h
PR fusionados (30 d)
132

Descripción

Per Ryan's suggestion here I am reposting this. This bug still occurs in typescript-go version 0.20260427.1

💻 Code
  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

Guía de contribución

Abrir la guía de contribución

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Evaluación

Este issue todavía no se ha evaluado.

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.