Skip to content

Bug: incorrect contextual typing on yield expression of generator function as discriminate of a unionΒ #51187

Closed
@shigma

Description

@shigma

Bug Report

πŸ”Ž Search Terms

generator function union contextual typing yield expression

πŸ•— Version & Regression Information

4.8.4

⏯ Playground Link

Playground link with relevant code

image

πŸ’» Code

type Action = () => (Generator<string, string, string[]> | string)

const b: Action = function* () {
    // expect `string[]`, actual `never`
    const c = yield ''
    return ''
}

πŸ™ Actual behavior

never

πŸ™‚ Expected behavior

string[]

Metadata

Metadata

Assignees

Labels

Fix AvailableA PR has been opened for this issue

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions