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

Unexpected "Object is possibly undefined" error #17240

Closed
chrisprice opened this issue Jul 17, 2017 · 2 comments · Fixed by #56908
Closed

Unexpected "Object is possibly undefined" error #17240

chrisprice opened this issue Jul 17, 2017 · 2 comments · Fixed by #56908
Labels
Duplicate An existing issue was already created

Comments

@chrisprice
Copy link

TypeScript Version: 2.3.4

Code

const foo = (bar?: { baz: number }) => {
    if (bar == null) {
        bar = { baz: 0 };
    }
    const baz = () => {
        console.log(bar.baz); // Object is possibly undefined
    };
    baz();
};

Playground link

Expected behavior:
No error

Actual behavior:
Error "Object is possibly undefined"

@ikatyang
Copy link
Contributor

Duplicate of #16889, see #9998 for more detail.

@ikatyang ikatyang marked this as a duplicate of #16889 Jul 17, 2017
@RyanCavanaugh RyanCavanaugh added the Duplicate An existing issue was already created label Jul 17, 2017
@mhegazy
Copy link
Contributor

mhegazy commented Aug 17, 2017

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

@mhegazy mhegazy closed this as completed Aug 17, 2017
@microsoft microsoft locked and limited conversation to collaborators Jun 14, 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

Successfully merging a pull request may close this issue.

4 participants