I have defined this type:
type RouteMap = { [k: string]: React.Route };
Which I am trying to apply like this:
const routes: RouteMap = {
setDomain: { title: 'Set Domain', component: SetDomain }
};
export default class MyClass extends React.Component<void, void> {
render() {
return (
<View style={styles.container}>
<NavigatorIOS initialRoute={routes.setDomain} />
</View>
);
}
}
But that is yielding this error:
Property 'setDomain' does not exist on type RouteMap.
This works if I try to access the property like so: routes['setDomain'] but i'd like to avoid that. Is there any way to let TypeScript still infer the keys from the assignment?