We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
This code is currently not allowed:
interface I { [index: 'a' | 'b']: number; }
Probably because it's pretty much equivalent to this code:
interface I { a: number; b: number; }
However, if the union is actually a type argument, it's not equivalent:
interface I<T> { [index: T]: number; }
I think this would be useful. Potentially with some extra syntax to help clarify the api, something like:
interface I<T: union> { [index: T]: number; }
For my specific use case, I am implementing a parsing library, and wish to have an API like this:
export type Parser<AstNodeName> = /* Some stuff involving AstNodeName */; export interface Grammar<AstNodeName> { [index: AstNodeName]: Parser<AstNodeName>; }
Which will be used like this:
type AstNodes = 'plus' | 'minus'; const myGrammar: Grammar<AstNodes> = { 'plus': (n: AstNodes) => doSomeStuff(n), 'minus': (n: AstNodes) => doDifferentStuff(n), }
The text was updated successfully, but these errors were encountered:
This is probably a duplicate of #2049, if I understand your request correctly.
Sorry, something went wrong.
Yep, I think it is.
No branches or pull requests
This code is currently not allowed:
Probably because it's pretty much equivalent to this code:
However, if the union is actually a type argument, it's not equivalent:
I think this would be useful. Potentially with some extra syntax to help clarify the api, something like:
For my specific use case, I am implementing a parsing library, and wish to have an API like this:
Which will be used like this:
The text was updated successfully, but these errors were encountered: