Skip to content

Instantly share code, notes, and snippets.

@Sammons
Created November 6, 2018 04:12
Show Gist options
  • Save Sammons/7e05a80463ef5446a9b7b681d196f2a5 to your computer and use it in GitHub Desktop.
Save Sammons/7e05a80463ef5446a9b7b681d196f2a5 to your computer and use it in GitHub Desktop.
type SettingTypeMap = {
 header: { color: keyof typeof colors; width: number };
 body: { width: number; height: number; logo: string; };
 footer: { fontSize: number; }
}
async function LookupSetting<
 SettingName extends keyof SettingTypeMap
 >(setting: SettingName): Promise<SettingTypeMap[SettingName]> {
 return {} as any; // replace with the actual logic to run a query
}
LookupSetting('header').then(result => {
 result.color // keyof typeof colors
 result.width // number
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment