microsoft / microsoft/TypeScript
Error messages should place most relevant information first.
@DanielRosenwasser がすでに取り組んでいます。
2019年2月5日 から。
- 主要言語
- Go
- スター
- 111k
- フォーク
- 14.4k
- 平均マージ
- 1日 19時間
- マージ済み PR(30日)
- 117
説明
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.
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
評価
この issue はまだ評価されていません。