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

noImplicitAny ignores implicit any on yield expression assignment #35105

Closed
TeoTN opened this issue Nov 14, 2019 · 1 comment · Fixed by #41348
Closed

noImplicitAny ignores implicit any on yield expression assignment #35105

TeoTN opened this issue Nov 14, 2019 · 1 comment · Fixed by #41348
Assignees
Labels
Breaking Change Would introduce errors in existing code Fixed A PR has been merged for this issue Rescheduled This issue was previously scheduled to an earlier milestone

Comments

@TeoTN
Copy link

TeoTN commented Nov 14, 2019

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:

@nmain
Copy link

nmain commented Nov 14, 2019

Related #32523

@RyanCavanaugh RyanCavanaugh added the Needs Investigation This issue needs a team member to investigate its status. label Nov 14, 2019
@RyanCavanaugh RyanCavanaugh added this to the TypeScript 3.8.1 milestone Nov 14, 2019
@RyanCavanaugh RyanCavanaugh added the Rescheduled This issue was previously scheduled to an earlier milestone label Aug 31, 2020
@typescript-bot typescript-bot added the Fix Available A PR has been opened for this issue label Oct 31, 2020
@DanielRosenwasser DanielRosenwasser added the Breaking Change Would introduce errors in existing code label Nov 3, 2020
@DanielRosenwasser DanielRosenwasser removed the Needs Investigation This issue needs a team member to investigate its status. label Nov 3, 2020
@rbuckton rbuckton added Fixed A PR has been merged for this issue and removed Fix Available A PR has been opened for this issue labels Dec 18, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Breaking Change Would introduce errors in existing code Fixed A PR has been merged for this issue Rescheduled This issue was previously scheduled to an earlier milestone
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants