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:
src/vendor/ata/index.ts(12,1): error TS2322: 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'.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 globalThisare too small.Changing one
Changing both
The text was updated successfully, but these errors were encountered: