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
classTest{foo?: Map<object,string>getFoo(obj: object){// "foo" is inferred as "Map<any, any>" instead of "Map<object, string>"constfoo=this.foo||(this.foo=newMap())foo.set(obj,1)// No error!}}
Expected behavior: Infer foo to be Map<object, string>
DanielRosenwasser
changed the title
RHS type of assignment expression used instead of LHS type
Use generic defaults for "empty" constructors of Array, Map, Set
Feb 13, 2019
It’s not possible to make this work without breaking other things, primarily preventing people from writing Map<string> and omitting the second type parameter. See #45648 for more detailed notes.
TypeScript Version: 3.4.0-dev.20190202
Search Terms:
Code
Expected behavior: Infer
foo
to beMap<object, string>
Actual behavior: Infers
foo
to beMap<any, any>
Playground Link: Click here
Related Issues: Maybe #7782
The text was updated successfully, but these errors were encountered: