Skip to content

2.4: Readonly<Map<k,v>> vs. ReadonlyMap<k,v> #16840

Open
@BurtHarris

Description

@BurtHarris

TypeScript Version: 2.4.1

Code

function GenMap() : ReadonlyMap<string, number> {
    const theMap = new Map<string, number>();
    theMap.set("one", 1);
    theMap.set("two", 2);
    return Object.freeze(theMap);
}

Expected behavior:
Compiles without error in tsc@<2.4.0

Actual behavior:

TryX.ts(5,5): error TS2322: Type 'Readonly<Map<string, number>>' is not assignable to type 'ReadonlyMap<s
tring, number>'.
  Property '[Symbol.iterator]' is missing in type 'Readonly<Map<string, number>>'.

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugA bug in TypeScriptDomain: lib.d.tsThe issue relates to the different libraries shipped with TypeScriptHelp WantedYou can do this

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions