Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Elaborate array and tuple relation errors #30916

Merged
merged 1 commit into from Apr 15, 2019

Conversation

jack-williams
Copy link
Collaborator

Fixes #30839

@@ -52,7 +52,7 @@ tests/cases/conformance/types/tuple/readonlyArraysAndTuples.ts(25,5): error TS27
!!! error TS2740: Type 'readonly string[]' is missing the following properties from type '[string, string]': 0, 1, pop, push, and 5 more.
mt = rt; // Error
~~
!!! error TS2740: Type 'readonly [string, string]' is missing the following properties from type '[string, string]': pop, push, reverse, shift, and 3 more.
!!! error TS4105: A 'readonly' tuple cannot be assigned to a mutable array-like type.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, I think the fact that these lack context is a bit of a problem. If these aren't acting as elaborations, then maybe both messages could be replaced with

The type '{0}' is considered 'readonly' and cannot be assigned to the mutable type '{1}'.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah yes, it slipped past me that these errors don't include Foo is not assignable to Bar. So:

  • The type '{0}' is considered 'readonly' and cannot be assigned to the mutable type '{1}'.

which can probably subsume both new error messages?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we remove the word "considered" here?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Works for me!

@DanielRosenwasser DanielRosenwasser merged commit 3dc78b6 into microsoft:master Apr 15, 2019
@DanielRosenwasser
Copy link
Member

Beautiful, thanks Jack!

@jack-williams
Copy link
Collaborator Author

Anytime!

@jack-williams jack-williams deleted the array-elaboration branch April 16, 2019 09:42
weswigham added a commit to weswigham/TypeScript that referenced this pull request May 6, 2019
weswigham added a commit that referenced this pull request May 14, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Poor error message elaborations for array-like types
3 participants