You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
function*sample(){consta=yield1// error, as expected, a is implicitly anyconst{ b }=yield1// no error, but expected, b is implicitly anyconst[c]=yield1// no error, but expected, c is implicitly any}
π Actual behavior
b, c implicitly have type any, but no error reported
π Expected behavior
Errors reported
The text was updated successfully, but these errors were encountered:
function*g1(){const{ a }=yield;// error: implicit anyconst{ b }: {b: string}=yield;// okconst{ c =1}=yield;// ok ??}function*g2(){const[a]=yield;// error: implicit anyconst[b]: [string]=yield;// okconst[c=1]=yield;// ok ??}
ah, on the second thought, if it is const binding, the type is not widening, which is not the same in the argument destructuring. You either end up having a type of const context or have inconsistency and widen the type even in const binding.
I'd say in this case it should be an error then. Although let would work just fine, for consistency, I'd also vote for the error.
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
π Actual behavior
b
,c
implicitly have typeany
, but no error reportedπ Expected behavior
Errors reported
The text was updated successfully, but these errors were encountered: