Created
November 6, 2018 04:12
-
-
Save Sammons/7e05a80463ef5446a9b7b681d196f2a5 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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