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

narrowed objects widen back when passed as arguments #20470

Closed
zpdDG4gta8XKpMCd opened this issue Dec 5, 2017 · 2 comments
Closed

narrowed objects widen back when passed as arguments #20470

zpdDG4gta8XKpMCd opened this issue Dec 5, 2017 · 2 comments
Labels
Duplicate An existing issue was already created

Comments

@zpdDG4gta8XKpMCd
Copy link

zpdDG4gta8XKpMCd commented Dec 5, 2017

interface A { test: null | string; }
declare const a: A;
declare function fn(a: A & { test: {} }): void;
if (a.test != null) {
    fn(a); // <-- expected to work, actual:
    // Argument of type 'A' is not assignable to parameter of type 'A & { test: {}; }'.
    //   Type 'A' is not assignable to type '{ test: {}; }'.
    //     Types of property 'test' are incompatible.
    //       Type 'string | null' is not assignable to type '{}'.
    //         Type 'null' is not assignable to type '{}'.
}
@RyanCavanaugh
Copy link
Member

Same as #10065

@RyanCavanaugh RyanCavanaugh added the Duplicate An existing issue was already created label Dec 5, 2017
@typescript-bot
Copy link
Collaborator

Automatically closing this issue for housekeeping purposes. The issue labels indicate that it is unactionable at the moment or has already been addressed.

@microsoft microsoft locked and limited conversation to collaborators Jul 3, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Duplicate An existing issue was already created
Projects
None yet
Development

No branches or pull requests

3 participants