Skip to content

Index signature pointing to any is too relaxed #24083

Closed
@inad9300

Description

@inad9300

How come this code fails...

type T = {
    [p: string]: string
}

function f(t: T) { }

f([]) // Index signature is missing in type 'undefined[]'.

...and even this one...

type T<S> = {
    [p: string]: S
}

function f<S>(t: T<S>) { }

f([]) // Index signature is missing in type 'undefined[]'.

...but this one doesn't?

type T = {
    [p: string]: any
}

function f(t: T) { }

f([])

I'm sorry if this has been pointed out before; it's difficult for me to look for related issues.

Metadata

Metadata

Assignees

No one assigned

    Labels

    QuestionAn issue which isn't directly actionable in code

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions