Skip to content

noImplicitAny ignores implicit any on yield expression assignment #35105

Closed
@TeoTN

Description

@TeoTN

TypeScript Version: 3.7.2 (playground)

Search Terms: generator implicitAny

Code

function* generator() {
    const value = yield;
    console.log(value);
}

const iterator = generator();
iterator.next();
iterator.next(5);

Expected behavior:
TypeScript Compiler with enabled noImplicitAny flag warns about implicit any with yield expression assignment.

function* generator() {
    const value: ExpectedType = yield call(fn); // Example from redux-saga
}

Actual behavior:
Yield expression is assigned implicitly as any because we're not able to infer the type. While I acknowledge that proper type check here is a difficult issue with quite a few other issues open, we should be forced to declare the expected type.

Playground Link

Related Issues:

Metadata

Metadata

Assignees

Labels

Breaking ChangeWould introduce errors in existing codeFixedA PR has been merged for this issueRescheduledThis issue was previously scheduled to an earlier milestone

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions