Typescript: Terrible error message for calling/constructing types

Created on 20 Jun 2019  路  4Comments  路  Source: microsoft/TypeScript

https://twitter.com/sebmck/status/1141776682275049472

image

Suggestions

This expression is not callable.
  Type '{0}' has no call signatures.

For unions:

This expression is not callable.
  No constituent of type '{0}' is callable.
This expression is not callable.
  Not all constituents of type '{0}' are callable.
    Type '{0}' has no call signatures.
This expression is not callable.
  Each member of the union type '{0}' has signatures, but none of those signatures are compatible with each other.

The same would be done for constructors.

This expression is not constructable.
  Type '{0}' has no construct signatures.
This expression is not constructable.
  No constituent of type '{0}' is constructable.
This expression is not constructable.
  Not all constituents of type '{0}' are constructable.
    Type '{0}' has no construct signatures.
This expression is not constructable.
  Each member of the union type '{0}' has signatures, but none of those signatures are compatible with each other.
Error Messages Experience Enhancement Fixed good first issue help wanted

Most helpful comment

"Constituent" doesn't seem like a commonly familiar word. Maybe "possibility"?

All 4 comments

"Constituent" doesn't seem like a commonly familiar word. Maybe "possibility"?

Should a separate issue be made for better formatting of complex types?

Also, @sebmck is right that type exploding/expanding/resolving is done too eagerly. VSCode could add a button (in the type error tooltip) to view the fully exploded type. Giving the user only the details they need to solve the problem is better for cognitive load. I just wanted to underline this concern, although I'm sure it's already on the minds of the TypeScript team.

Yeah, it is, the interactive diagnostics PR implements a framework for similar (expanding bits of error messages, linkifying bits) we just need to sell the vscode team on the UI. :3

Thanks @dragomirtitian!!!!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

CyrusNajmabadi picture CyrusNajmabadi  路  3Comments

Roam-Cooper picture Roam-Cooper  路  3Comments

DanielRosenwasser picture DanielRosenwasser  路  3Comments

Antony-Jones picture Antony-Jones  路  3Comments

blendsdk picture blendsdk  路  3Comments