Suggestion
π Search Terms
Multiple more than one index type property signature type specific member mapping TypeScript TS
β
Viability Checklist
My suggestion meets these guidelines:
β Suggestion
Put further restrictions on index signatures being mapped to member types, driven by the type of the index signature. Basically add multiple index signatures to an interface that map different type keys to different type members. Hugely increases the power of index signatures. Blocked by #26797.
π Motivating Example
This:
export type ColorIdentifier =
`${string}.${string}`
| 'background'
| 'contrastActiveBorder' | 'contrastBorder' | 'focusBorder'
| 'descriptionForeground' | 'errorForeground' | 'foreground';
export type ThemeScopeKey = `[${string}]`;
export interface IThemeScopedColorCustomizations {
[colorId: ColorIdentifier]: string;
}
export interface IColorCustomizations {
[colorIdOrThemeScope: ColorIdentifier | ThemeScopeKey]: IThemeScopedColorCustomizations | string;
}
Could be more accurately specified as:
export type ColorIdentifier =
`${string}.${string}`
| 'background'
| 'contrastActiveBorder' | 'contrastBorder' | 'focusBorder'
| 'descriptionForeground' | 'errorForeground' | 'foreground';
export type ThemeScopeKey = `[${string}]`;
export interface IThemeScopedColorCustomizations {
[colorId: ColorIdentifier]: string;
}
export interface IColorCustomizations {
[colorId: ColorIdentifier]: string;
[themeScope: ThemeScopeKey]: IThemeScopedColorCustomizations;
}
π» Use Cases
The vscode repo is full of interface collections that could make immediate use of this..
Suggestion
π Search Terms
Multiple more than one index type property signature type specific member mapping TypeScript TS
β Viability Checklist
My suggestion meets these guidelines:
β Suggestion
Put further restrictions on index signatures being mapped to member types, driven by the type of the index signature. Basically add multiple index signatures to an interface that map different type keys to different type members. Hugely increases the power of index signatures. Blocked by #26797.
π Motivating Example
This:
Could be more accurately specified as:
π» Use Cases
The
vscoderepo is full of interface collections that could make immediate use of this..