Skip to content

Type width in error messages #61829

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

bjatkin
Copy link

@bjatkin bjatkin commented Jun 7, 2025

Fixes #45896

Currently the complier will print "... is not assignable..." errors on a single line

prettyFormatLongTypes.ts: - error TS2882: Type '{ b: { c: { e: { f: string; }; }; }; }' is not assignable to type '{ b: { c: { e: { f: number; }; }; }; }'
 The types of 'b.c.e.f' are incompatible between these types.
    Type 'string' is not assignable to type 'number'.

This PR puts types onto their own lines when they are >30 characters in length

prettyFormatLongTypes.ts: - error TS2882: Type:
  { b: { c: { e: { f: string; }; }; }; }

is not assignable to type:
  { b: { c: { e: { f: number; }; }; }; }

  The types of 'b.c.e.f' are incompatible between these types.
    Type 'string' is not assignable to type 'number'.

This PR is based on #54832 which was never merged.

This PR in the typscript-go repo implements the same behavior microsoft/typescript-go#1099

@github-project-automation github-project-automation bot moved this to Not started in PR Backlog Jun 7, 2025
@typescript-bot typescript-bot added the For Uncommitted Bug PR for untriaged, rejected, closed or missing bug label Jun 8, 2025
@bjatkin
Copy link
Author

bjatkin commented Jun 8, 2025

@microsoft-github-policy-service agree

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
For Uncommitted Bug PR for untriaged, rejected, closed or missing bug
Projects
Status: Not started
Development

Successfully merging this pull request may close these issues.

Use the width of a type to add newlines in type assignment error messages
2 participants