I get a compiler error when I run npm test
after I make a Map with the factory function that consumes the 'collection' argument (see https://immutable-js.github.io/immutable-js/docs/#/Map/Map). There is no problem when I use the factory function that consumes the 'obj' argument. Why does this variant not work? For my purpose I need to add my own type to the Map, which does not work as well with the 'obj' notation, but seems to work fine with the 'collection' notation.
Strangely enough, this does not happen when I run npm start or when I run the test through Intellij, instead of the command line.
fit('Immutables test', () => {
//collection notation
const map = Map([
['key', 'value']
]);
//obj notation
const map2 = Map({ 'key': 'value', 'key2': 'value2' });
});
The result of above test code is a failed unit test:
ERROR in .../my.spec.ts:162:21 - error TS2345: Argument of type 'string[][]' is not assignable to parameter of type '{ [key: string]: {}; }'.
Index signature is missing in type 'string[][]'.
162 const map = Map([
~
163 ['key', 'value']
~~~~~~~~~~~~~~~~~~~~~~
164 ]);
~~~~~
The project is on dependencies:
"@angular/core": "8.1.0"
, "immutable": "4.0.0-rc.12"
, "typescript": "<3.5.0"
, "karma": "4.1.0"
and "jasmine-core": "3.4.0"
.
I have no idea why only npm test
would fail here. My only clue is that Immutable.js used to have an Iterable
interface, which has been removed since version 4.0.0, but the Map factory function in question still depends on an argument of type Iterable
. Can we be sure this is the EcmaScript type?