Skip to content

wrong type inference in Promise #31266

Description

@dislido

TypeScript Version: 3.4.3

Search Terms:

Code

let foo: string | undefined;
if (!foo) foo = 'hello';

foo.length; // ok

new Promise(resolve => resolve(foo.length));
//                              ^ should be string, but inferred as string | undefined

Expected behavior:

Actual behavior:

Playground Link:

Related Issues:

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    DuplicateAn existing issue was already created

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions