Skip to content

assigning an array to a variable of type Record<string, any> should be an error #50439

@ivanhofer

Description

@ivanhofer

Bug Report

An array is assignable to a variable of type Record<string, any>.
When using any other type instead of any, an error gets correctly shown e.g Record<string, unknown>.

🔎 Search Terms

record, array, any

🕗 Version & Regression Information

This issue seems to occur in all TypeScript versions.

⏯ Playground Link

Playground link with relevant code

💻 Code

let x: Record<string, any> = {}
x = {}
x = [] // this should show an error

let y: Record<string, unknown> = {}
y = {}
y = [] // correctly shows an error

🙁 Actual behavior

An array is assignable to a variable of type Record<string, any>

🙂 Expected behavior

When using any for a Record, an error shold be shown if an array gets assigned to it.

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