Skip to content

Find first callable/constructable type in union when appropriate #26895

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

Merged
merged 6 commits into from
Sep 7, 2018

Conversation

DanielRosenwasser
Copy link
Member

Fixes #26449

Type '(a: string, b: number) => string | number' is not assignable to type '(a: string, b: number) => number'.
Type 'string | number' is not assignable to type 'number'.
Type 'string' is not assignable to type 'number'.
Type '(a: string, b: number) => string | number' is not assignable to type '(a: string, b: number) => string'.
Copy link
Member

Choose a reason for hiding this comment

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

We could avoid these baseline changes if we choose the last matching invokable instead of the first.

Copy link
Member

@RyanCavanaugh RyanCavanaugh left a comment

Choose a reason for hiding this comment

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

+1 for finding the last signature

@DanielRosenwasser DanielRosenwasser dismissed RyanCavanaugh’s stale review September 5, 2018 22:25

Picking the last type isn't any better, so I don't think it's worth changing the implementation just to maintain baselines. Plus, I would argue picking the first signature is usually more desirable for anonymous arrow types anyway.

@DanielRosenwasser DanielRosenwasser merged commit cf2f339 into master Sep 7, 2018
@DanielRosenwasser DanielRosenwasser deleted the callableErrors branch September 7, 2018 07:06
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.

3 participants