Skip to content

Implicit anys with Map even if noImplicitAny is enabled #35259

Closed
@Daniel15

Description

@Daniel15

TypeScript Version: vNightly in Playground

Search Terms:
inferred any, implicit any, unsound

Code

function getStrings(): Map<string, string> {
  const val = new Map();
  val.set(42, true);
  return val;
}

Expected behavior:
I expected this to throw an error if noImplicitAny is enabled.

For what it's worth, Flow handles this correctly.

Actual behavior:
No errors

Playground link

Related Issues:
No

Metadata

Metadata

Assignees

No one assigned

    Labels

    DuplicateAn existing issue was already created

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions