microsoft / microsoft/TypeScript
Compiler error message improvement: Special casing container objects
Personne n'a encore pris cette issue.
- Langage dominant
- Go
- Étoiles
- 111k
- Forks
- 14.4k
- Merge moyen
- 1 j 19 h
- PR mergées (30 j)
- 117
Description
Search Terms
array promise container error message compare
Suggestion
Could it be worth having an extra special case message when the only difference is that you haven't included an array indicator instead of listing the property differences e.g.
3.7:
src/index.ts:356:5 - error TS2322: Type '{ renderedMessage: string; id: string; category: 0 | 1 | 2 | 3; code: number; start: number | undefined; }[][]' is not assignable to type '{ renderedMessage: string; id: string; category: 0 | 1 | 2 | 3; code: number; start: number | undefined; }[]'.
Type '{ renderedMessage: string; id: string; category: 0 | 1 | 2 | 3; code: number; start: number | undefined; }[]' is missing the following properties from type '{ renderedMessage: string; id: string; category: 0 | 1 | 2 | 3; code: number; start: number | undefined; }': renderedMessage, id, category, code, start
356 errors,
~~~~~~
src/index.ts:235:3
235 errors: {
~~~~~~
The expected type comes from property 'errors' which is declared here on type 'TwoSlashReturn'
To:
src/index.ts:356:5 - error TS2322: Type '{ renderedMessage: string; id: string; category: 0 | 1 | 2 | 3; code: number; start: number | undefined; length: number | undefined; }[][]' is not assignable to type '{ renderedMessage: string; id: string; category: 0 | 1 | 2 | 3; code: number; start: number | undefined; length: number | undefined; }[]'.
Type '{ renderedMessage: string; id: string; category: 0 | 1 | 2 | 3; code: number; start: number | undefined; length: number | undefined; }[]' is in an array here:
356 errors,
~~~~~~
src/index.ts:235:3
235 errors: {
~~~~~~
But not here
and the reverse?
Use Cases
Any case of mismatched types where the difference is that the object on one side of the comparison is the same object but wrapped in an array. Perhaps this could also work for a Promise too?
Checklist
My suggestion meets these guidelines:
- This wouldn't be a breaking change in existing TypeScript/JavaScript code
- This wouldn't change the runtime behavior of existing JavaScript code
- This could be implemented without emitting different JS based on the types of the expressions
- This isn't a runtime feature (e.g. library functionality, non-ECMAScript syntax with JavaScript output, etc.)
- This feature would agree with the rest of TypeScript's Design Goals.
Guide de contribution
Ouvrir le guide de contribution
Par où commencer
- Lisez l'issue en entier, puis le guide de contribution du projet.
- Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
- Forkez le dépôt et travaillez sur une branche.
- Ouvrez une pull request qui référence le numéro de l'issue.
Piste de recherche
Commencez par reproduire l’exemple de array-mismatch et l’exemple lié de Promise dans le TypeScript playground. L’issue ne nomme aucun fichier du compilateur ni aucun test ; suivez donc le chemin de génération des diagnostics après avoir établi la sortie actuelle ; le travail est terminé lorsque les diagnostics spécifiques au conteneur demandés sont couverts sans modifier le comportement à l’exécution.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Évaluation
- Stack technique
- typescript
- Domaine
- compilers
- Type d'issue
- Fonctionnalité
- Difficulté
- 5/5
- Temps estimé
- Plus d'une semaine
- Activité
- À l'abandon
- Clarté
- Plutôt claire
- Accessibilité débutants
- 30/100