Skip to content

Instantly share code, notes, and snippets.

@danvk
Created January 22, 2019 20:20
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save danvk/39a73aeebdf02cd4f429851bf8471140 to your computer and use it in GitHub Desktop.
Save danvk/39a73aeebdf02cd4f429851bf8471140 to your computer and use it in GitHub Desktop.
const inferKeys = <V extends {}>() => <K extends string>(x: Record<K,V>): Record<K,V> => x;
const INIT_VIEW = inferKeys<Partial<MapProps>>()({
nyc: {
center: [-73.991284, 40.741263],
zoom: [14.5],
pitch: [45],
bearing: [-17.6],
},
sf: {
center: [-73.991284, 40.741263],
zoom: [14.5],
pitch: [45],
bearing: [-17.6],
}
});
export function render(): JSX.Element {
return (
<Map
style="mapbox://styles/mapbox/streets-v9"
{...INIT_VIEW.nyc} // ok
>
{ /* ... */ }
</Map>
);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment