microsoft / microsoft/TypeScript

typeToString doesn't respect TypeFormatFlags.MultilineObjectLiterals

Open
#61,348 0 comments 1 reaction 1 assignee View on GitHub

@weswigham is already working on this.

Since Mar 20, 2025.

Needs Investigation
Dominant language
Go
Stars
111k
Forks
14.3k
Avg merge
2d 4h
Merged PRs (30d)
132

Description

### 🔎 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

```ts
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!

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.