microsoft / microsoft/TypeScript
Error messages should place most relevant information first.
@DanielRosenwasser is already working on this.
Since Feb 5, 2019.
- Dominant language
- Go
- Stars
- 111k
- Forks
- 14.3k
- Avg merge
- 2d 4h
- Merged PRs (30d)
- 132
Description
Here's an actual example of an error message that can go wrong in our library when mispelling a property when creating an object literal:
[ts]
Type '{ containers: { nginx: { image: string; memory: number; portMappings: NetworkListener[]; enviroment: number; }; }; }' is not assignable to type 'FargateTaskDefinitionArgs'.
Types of property 'containers' are incompatible.
Type '{ nginx: { image: string; memory: number; portMappings: NetworkListener[]; enviroment: number; }; }' is not assignable to type 'Record<string, Container>'.
Property 'nginx' is incompatible with index signature.
Type '{ image: string; memory: number; portMappings: NetworkListener[]; enviroment: number; }' is not assignable to type 'Container'.
Object literal may only specify known properties, but 'enviroment' does not exist in
type 'Container'. Did you mean to write 'environment'? [2322]
- fargateService.d.ts(169, 5): The expected type comes from property 'taskDefinitionArgs'
which is declared here on type 'FargateServiceArgs'
The funny thing here is that the final parts of the error message are superb. Namely:
- Object literal may only specify known properties, but 'enviroment' does not exist in
type 'Container'. Did you mean to write 'environment'? [2322]
- fargateService.d.ts(169, 5): The expected type comes from property 'taskDefinitionArgs'
which is declared here on type 'FargateServiceArgs'
However, the actual output is quite cluttered and hard to glean the information from. This is esp. true in an ide setting where one sees something like this:

This view is particularly problematic due to the wrapping and wall-of-goop nature of this type of error.
My suggestion would be to invert the information being provided by errors. Give the most specific and directly impactful information first (i.e. Object literal may only specify known properties, but 'enviroment' does not exist in type 'Container'. Did you mean to write 'environment'?), and then follow that up with all the extra details that can be used to dive deeper into things when that isn't clear enough.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.