Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Adds a error diagnostic with newlines if either source or target are longer than 30 characters on type is not assignable to type #54832

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

Conversation

orta
Copy link
Contributor

@orta orta commented Jun 29, 2023

Fixes #45896 - this keeps the formatting I recommended in that issue, but that doesn't have to be the answer:

// a is 31 chars long
let a = { b: { c: { e: { f: 123 } } } };
let b = "hello"

b=a

Gives:

Type:
{ b: { c: { e: { f: number; }; }; }; }

is not assignable to type:
string

Which is the simplest version of this PR via diagnostics, there's space here for a few answers which I can look at (having 3 diags, 1 with newlines for source, 1 with newlines for target, 1 with newlines for both)

@typescript-bot typescript-bot added the For Uncommitted Bug PR for untriaged, rejected, closed or missing bug label Jun 29, 2023
@orta
Copy link
Contributor Author

orta commented Jun 29, 2023

I'm not too convinced on indenting unless there is more whitespace:

Type:
  { b: { c: { e: { f: number; }; }; }; }

is not assignable to type:
  string

feels tight to me?

Yet:

Type:

  { b: { c: { e: { f: number; }; }; }; }

is not assignable to type:

  string

Feels a bit too whitespacey though? But open to ideas

@fbartho
Copy link

fbartho commented Jun 29, 2023

I like the indenting personally, not the extra newlines.

eg. (I prefer this:)

Type:
  { b: { c: { e: { f: number; }; }; }; }

is not assignable to type:
  string

[Assuming you wanted bike shedding opinions 😉]

@vdawg-git
Copy link

This looks great! The indents are nice, but extra lines do indeed add too much whitespace.

Copy link
Member

@sandersn sandersn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like this but @DanielRosenwasser should also sign off.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
For Uncommitted Bug PR for untriaged, rejected, closed or missing bug
Projects
Status: Waiting on reviewers
Development

Successfully merging this pull request may close these issues.

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