Skip to content

Better errors relating callable/constructable types in unions #26449

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

Closed
DanielRosenwasser opened this issue Aug 14, 2018 · 0 comments
Closed
Assignees
Labels
Bug A bug in TypeScript Domain: Error Messages The issue relates to error messaging Fixed A PR has been merged for this issue

Comments

@DanielRosenwasser
Copy link
Member

From @rkirov at DefinitelyTyped/DefinitelyTyped#28044 (comment):

interface IDirectiveLinkFn<TScope> {
    (scope: TScope): void;
}

interface IDirectivePrePost<TScope> {
    pre?: IDirectiveLinkFn<TScope>;
    post?: IDirectiveLinkFn<TScope>;
}

export let blah: IDirectiveLinkFn<number> | IDirectivePrePost<number> = (x: string) => {}

Expected:

Type '(x: string) => void' is not assignable to type 'IDirectiveLinkFn<number>'.
  Types of parameters 'x' and 'scope' are incompatible.
    Type 'number' is not assignable to type 'string'.

Actual:

Type '(x: string) => void' is not assignable to type 'IDirectiveLinkFn<number> | IDirectivePrePost<number>'.
  Type '(x: string) => void' has no properties in common with type 'IDirectivePrePost<number>'.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug A bug in TypeScript Domain: Error Messages The issue relates to error messaging Fixed A PR has been merged for this issue
Projects
None yet
Development

No branches or pull requests

3 participants