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

Typescript: make ObservableMap assignable to ES6 Map #503

Closed
Strate opened this issue Aug 22, 2016 · 5 comments
Closed

Typescript: make ObservableMap assignable to ES6 Map #503

Strate opened this issue Aug 22, 2016 · 5 comments

Comments

@Strate
Copy link
Contributor

Strate commented Aug 22, 2016

As for now, ObservableMap<T> is not assignable to ES6 Map<string, T>, due to incompatibles of some methods, at least because:

Type 'ObservableMap<T>' is not assignable to type 'Map<string, T>'.
      Types of property 'delete' are incompatible.
        Type '(key: string) => void' is not assignable to type '(key: string) => boolean'.
          Type 'void' is not assignable to type 'boolean'.

It sould be good to make ObservableMap interface be compatible to Map, for refactoring purposes.

@mweststrate
Copy link
Member

Good point. I'll update it

@valoricDe
Copy link

Hi, my editor tells me that:

Error:(6, 2) TS2322: Type 'ObservableMap<{}>' is not assignable to type 'Map<string, ITick>'.
 Types of property 'forEach' are incompatible.
 Type '(callback: (value: {}, key: string, object: IKeyValueMap<{}>) => void, thisArg?: any) => void' is not assignable to type '(callbackfn: (value: ITick, index: string, map: Map<string, ITick>) => void, thisArg?: any) => void'.
 Types of parameters 'callback' and 'callbackfn' are incompatible.
 Type '(value: ITick, index: string, map: Map<string, ITick>) => void' is not assignable to type '(value: {}, key: string, object: IKeyValueMap<{}>) => void'.
 Types of parameters 'map' and 'object' are incompatible.
 Type 'IKeyValueMap<{}>' is not assignable to type 'Map<string, ITick>'.
 Property 'clear' is missing in type 'IKeyValueMap<{}>'.

@mweststrate
Copy link
Member

@Valorize what is the code you get the error on, and the variable definition. Which version of typescript? (in your IDE, ide's sometimes pick a different version then you intended to compile with)

@arvind1234
Copy link

arvind1234 commented Oct 12, 2017

Hi, I am unable to assign ObservableMap object to Map. I see the following error when I try to assign:
Argument of type 'ObservableMap' is not assignable to parameter of type 'Map<string, Foo>'.
Property '[Symbol.toStringTag]' is missing in type 'ObservableMap'.

I am basically trying to pass an ObservableMap object to a function that is expecting a Map<string, Foo>. I also tried doing observableMapObj.toJS() - but still hitting the same typescript error. Any pointers on how I can get this to work?

I am running TS version 2.5.3

@eddiegroves
Copy link

I've come across the same thing @arvind1234 and I've raised #1204 to ask if this should still work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants