Skip to content

Get object property by typed value #10951

Closed
@wclr

Description

@wclr

This currenlty doen't work:

let person: { name: string, age: number } = {
  name: 'John', age: 10
} 
type NameOrAge = 'name' | 'age'
let prop: NameOrAge = 'name'

let nameOrAge = person[prop] // `nameOrAge`  would take tape of `string | number`

image

Is it going to work in near future?

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