Skip to content

in keyof interface index signature #28192

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
4 tasks done
ardalanamini opened this issue Oct 28, 2018 · 1 comment
Closed
4 tasks done

in keyof interface index signature #28192

ardalanamini opened this issue Oct 28, 2018 · 1 comment
Labels
Duplicate An existing issue was already created

Comments

@ardalanamini
Copy link

ardalanamini commented Oct 28, 2018

Search Terms

typescript interface index signature keyof

Suggestion

Make in keyof accessible to interface index signature

Use Cases

Suppose I have a class which on construct adds some getters and setters to itself by the provided object interface

Examples

interface Base<T extends object = {}> {
  [K in keyof T]: T[K];

  [key: string]: any;
}

class Base<T extends object = {}> {
  constructor(item: T) {
    this.foo = item.foo;
  }
}

const base = new Base({ foo: "bar" });

base.foo; // string

base.bar; // any

Checklist

My suggestion meets these guidelines:

  • This wouldn't be a breaking change in existing TypeScript / JavaScript code
  • This wouldn't change the runtime behavior of existing JavaScript code
  • This could be implemented without emitting different JS based on the types of the expressions
  • This isn't a runtime feature (e.g. new expression-level syntax)
@weswigham
Copy link
Member

Duplicate of #13573

@weswigham weswigham marked this as a duplicate of #13573 Oct 29, 2018
@weswigham weswigham added the Duplicate An existing issue was already created label Oct 29, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Duplicate An existing issue was already created
Projects
None yet
Development

No branches or pull requests

2 participants