Use the width of a type to add newlines in type assignment error messages #45896
Comments
Would be nice if rusty |
Hey @orta, I am a typescript beginner and want to contribute here, could you guide me where to start? |
Sure, first read the READMEs/contributing guides - I think all of the changes will probably live inside
|
Then it becomes a garden path sentence:
"What's a type string? Does that mean literal string types? Oh wait, it means the actual type 'string'." It's better with the quotes. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Today we ship a one-type-fits-all style for printing type is not assignable to type messages. We'd like to improve this in a pretty simple manner: by occasionally adding newlines. For example with this arbitrary comparison:
Looks like this today:
I propose that because both of the printed types are longer than 20-30 chars, then we switch to:
Key details
Some Examples
No changes
src/index.ts(21,1): error TS2322: Type 'string' is not assignable to type 'number'.
src/index.ts(21,1): error TS2322: Type 'string' is not assignable to type 'number'.
No change! (Though a part of me does really want to drop the quotes for primitives)
No change!
{}
andWindow & typeof globalThis
are too small.Changing one
Changing both
The text was updated successfully, but these errors were encountered: