Skip to content

Index access expressions #831

Open
Open

Description

@ssalbdivad

Would allow expressions like the following:

const types = scope({
  base: {
    foo: "true",
    bar: "false",
  },
  // 1:1 with TS
  foo: "base['foo']",
  // Allow more convenient dot notation from JS
  bar: "base.bar",
});

Should check that the accessed expression extends keyof the base type, otherwise should result in a semantic validation error.

Activity

  1. moved this from To do to Backlog in arktypeioon Jul 24, 2023
  2. drwpwrs commented on Feb 8, 2025

    @drwpwrs
    Contributor

    Would be great for generics.

    const types = scope({
      base: {
        foo: "true",
        bar: "false"
      },
      "baz<t extends keyof base>": "base[t]"
    })
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

    No labels
    No labels

    Type

    No type

    Projects

    • Status
      Backlog

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions