-
Notifications
You must be signed in to change notification settings - Fork 12.9k
Open
Labels
QuestionAn issue which isn't directly actionable in codeAn issue which isn't directly actionable in code
Description
π Search Terms
multi-group dynamic keys
β Viability Checklist
- 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. library functionality, non-ECMAScript syntax with JavaScript output, new syntax sugar for JS, etc.)
- This isn't a request to add a new utility type: https://github.com/microsoft/TypeScript/wiki/No-New-Utility-Types
- This feature would agree with the rest of our Design Goals: https://github.com/Microsoft/TypeScript/wiki/TypeScript-Design-Goals
β Suggestion
If I have multi-group character mode to create responsible objects, I want to define multi-group dynamic keys
example
type Test<SingularAssociationName extends string, PluralAssociationName extends string>{
[`get${SingularAssociationName }`]:()=>number;
[`set${SingularAssociationName }`]:(a:number)=>void;
[`get${PluralAssociationName }`]:()=>Array<number>;
[`set${PluralAssociationName }`]:(a:Array<number>)=>void;
}
OR
type Test<SingularAssociationName extends string, PluralAssociationName extends string>{
[Key1 in `get${SingularAssociationName }`]:()=>number;
[Key2 in `set${SingularAssociationName }`]:(a:number)=>void;
[Key3 in `get${PluralAssociationName }`]:()=>Array<number>;
[Key4 in `set${PluralAssociationName }`]:(a:Array<number>)=>void;
}
π Motivating Example
If I have multi-group character mode to create responsible objects, I want to define multi-group dynamic keys
example
type Test<SingularAssociationName extends string, PluralAssociationName extends string>{
[`get${SingularAssociationName }`]:()=>number;
[`set${SingularAssociationName }`]:(a:number)=>void;
[`get${PluralAssociationName }`]:()=>Array<number>;
[`set${PluralAssociationName }`]:(a:Array<number>)=>void;
}
OR
type Test<SingularAssociationName extends string, PluralAssociationName extends string>{
[Key1 in `get${SingularAssociationName }`]:()=>number;
[Key2 in `set${SingularAssociationName }`]:(a:number)=>void;
[Key3 in `get${PluralAssociationName }`]:()=>Array<number>;
[Key4 in `set${PluralAssociationName }`]:(a:Array<number>)=>void;
}
π» Use Cases
- What do you want to use this for?
- What shortcomings exist with current approaches?
- What workarounds are you using in the meantime?
Metadata
Metadata
Assignees
Labels
QuestionAn issue which isn't directly actionable in codeAn issue which isn't directly actionable in code