Skip to content

Dynamic function typings based on string params passed #10660

Closed
@wclr

Description

@wclr

Probably this is an issue of dynamic typing, didn't find exact here in the issues (probably you will point to).

Is it possible to do typing and achieve types flow of such thing:

function getProp(prop: string, obj: any) {
  return obj[prop]
}  

let obj: { id: number } = { id: 1 }

getProp('id', obj). // there should flow number type

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