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
interfaceMyType{id?: number;name: string;}functionmyFunc(listOrMap: MyType[]|Map<string,MyType>): void{// When `noImplicitAny` is on, obj parameter is correctly inferred as `MyType`// When `noImplicitAny` is off, obj parameter is inferred as `any`listOrMap.forEach((obj)=>{deleteobj.id;});}
π Actual behavior
With noImplicitAny=false, the type of the forEach parameter is inferred as any.
π Expected behavior
With noImplicitAny=false, the type of the forEach parameter is inferred as MyType
Additional information about the issue
Fyi, the type is correctly inferred when noImplicitAny=true, or if not using the union type for myFunc's parameter
The text was updated successfully, but these errors were encountered:
π Search Terms
noImplicitAny
any
union
π Version & Regression Information
β― Playground Link
https://www.typescriptlang.org/play?noImplicitAny=false&ts=4.9.5#code/JYOwLgpgTgZghgYwgAgLIE8Aq6AOKDeAUMicsACYD8AXMiAK4C2ARtANzGkhyMS0DOYKKADmHAL6FCMeiARhgAexDJG6AGKyEACgA2wQQHkoqODloZseANoBdZAB80ZgDyDhIEQBo0WXBAA+AEpaADdFCmQiUmR9IxMzADoYRSgAUUQAC21tRWYAKyDkAF4AqM4YknIIXQhIZDz8xIoOGPEgiUIgA
π» Code
π Actual behavior
With
noImplicitAny=false
, the type of theforEach
parameter is inferred asany
.π Expected behavior
With
noImplicitAny=false
, the type of theforEach
parameter is inferred asMyType
Additional information about the issue
Fyi, the type is correctly inferred when
noImplicitAny=true
, or if not using the union type formyFunc
's parameterThe text was updated successfully, but these errors were encountered: