镜像站点 · 本页由第三方 GitHub 只读镜像提供,非 GitHub 官方站点,不接受任何登录或凭据输入。前往 github.com
Skip to content

Dynamic function typings based on string params passed #10660

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

Activity

  1. gcnew commented on Sep 1, 2016

    @gcnew
    Contributor

    Rumor has it that it was once considered in a distant whimsical land, where unicorns walk freely under rainbows and mighty wombats support the sky. It is, however, deemed intractable for the feeble human beings.

    Use #1295 as a starting point, see #10425.

  2. wclr commented on Sep 1, 2016

    @wclr
    Author

    Marin Marinov (@gcnew) thanks for pointing on that

  3. mhegazy commented on Sep 2, 2016

    @mhegazy
    Contributor

    indeed duplicate.

  4. locked and limited conversation to collaborators on Jun 19, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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