Typescript seamless-immutable array within object created with Immutable.from not inferred to array

777 views Asked by At

I'm having a problem with seamless-immutable and Typescript. When I create an object as below, which contains an array, and then "get" that array from the created immutable object the type system can't infer that to be an immutable array and leads to an error of:

[ts] Cannot invoke an expression whose type lacks a call signature. Type > '((callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any) => U[]) | (...' has no compatible call signatures.

Code:

import * as SeamlessImmutable from "seamless-immutable"

const numbers = [1, 2, 3, 4, 5]

const immutableObject = SeamlessImmutable.from({
  numbers
})

const immutableNumbers = immutableObject.getIn(["numbers"])

immutableNumbers.map(number => number * 2)

Using:

  • Typescript 2.6.1
  • seamless-immutable 7.1.1
  • @types/seamless-immutable 7.1.1

Any suggestions? Type case to something? On what would makes the most sense here?

0

There are 0 answers