Microsoft/TypeScript

No report of implicit any type in a generator when destructuring

Open

#43.172 geöffnet am 10. März 2021

Auf GitHub ansehen
 (5 Kommentare) (0 Reaktionen) (0 zugewiesene Personen)TypeScript (6.726 Forks)batch import
BugDomain: check: Type InferenceHelp Wanted

Repository-Metriken

Stars
 (48.455 Stars)
PR-Merge-Metriken
 (Durchschn. Merge 6T 17h) (9 gemergte PRs in 30 T)

Beschreibung

Bug Report

🔎 Search Terms

no implicit any, generator, yield, destructure #41348 - Report implicit any error for 'yield' result with no contextual type

🕗 Version & Regression Information

TypeScript 4.2.3

⏯ Playground Link

Playground link with relevant code

💻 Code

function* sample() {
    const a = yield 1 // error, as expected, a is implicitly any
    const { b } = yield 1 // no error, but expected, b is implicitly any
    const [c] = yield 1 // no error, but expected, c is implicitly any
}

🙁 Actual behavior

b, c implicitly have type any, but no error reported

🙂 Expected behavior

Errors reported

Contributor Guide