Skip to content

() => void is assignable to Record<string, any> #53484

@aaditmshah

Description

@aaditmshah

Bug Report

🔎 Search Terms

  1. function
  2. record
  3. any
  4. mapped type

🕗 Version & Regression Information

I see the bug in all the versions of TypeScript, from v3.3.3 to v5.0.2, and even in the Nightly version.

  • This is the behavior in every version I tried, and I reviewed the FAQ for entries about mapped types.

⏯ Playground Link

Playground link with relevant code

💻 Code

const x: Record<string, any> = () => {};

🙁 Actual behavior

I do not get any type error.

🙂 Expected behavior

I expected to get the following type error.

Type '() => void' is not assignable to type 'Record<string, any>'.
  Index signature for type 'string' is missing in type '() => void'.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Working as IntendedThe behavior described is the intended behavior; this is not a bug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions