Skip to content

noImplicitAny ignores implicit any on yield expression assignment #35105

Closed

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:

Activity

  1. nmain commented on Nov 14, 2019

    @nmain

    Related #32523

  2. added
    Needs Investigation
    on Nov 14, 2019
  3. added
    Rescheduled
    on Aug 31, 2020
  4. added
    Fix Available
    on Oct 31, 2020
  5. added
    Breaking Change
    on Nov 3, 2020
  6. removed
    Needs Investigation
    on Nov 3, 2020
  7. added
    Fixed
    and removed
    Fix Available
    on Dec 18, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

Breaking ChangeFixedRescheduled

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions