TypeScript icon indicating copy to clipboard operation
TypeScript copied to clipboard

typeToString doesn't respect TypeFormatFlags.MultilineObjectLiterals

Open adrianstephens opened this issue 10 months ago • 0 comments

🔎 Search Terms

typeToString

🕗 Version & Regression Information

This is the behavior in every version I tried, and I reviewed the FAQ for entries about typeToString

⏯ Playground Link

No response

💻 Code

const result = typeChecker.typeToString(
  type,
  enclosingDeclaration,
  ts.TypeFormatFlags.UseAliasDefinedOutsideCurrentScope
  | ts.TypeFormatFlags.NoTruncation
  | ts.TypeFormatFlags.MultilineObjectLiterals
)

🙁 Actual behavior

When type is the type of an object literal, the ts.TypeFormatFlags.MultilineObjectLiterals flag causes multiple spaces to be generated between the properties, but not newlines.

🙂 Expected behavior

When type is the type of an object literal, the ts.TypeFormatFlags.MultilineObjectLiterals flag should cause newlines to be generated between the properties.

Additional information about the issue

I'm reporting this because on investigation I found the problem, but in order to generate a PR, I need an issue to refer to!

adrianstephens avatar Mar 04 '25 20:03 adrianstephens