Quantcast
Channel: Active questions tagged react-native+typescript - Stack Overflow
Viewing all articles
Browse latest Browse all 6287

how to make a type with keys as values from another type in typescript

$
0
0

I have a object

const navigatorNames: NavigatorNamesType = {    homeNavigation: 'HomeNavigation',    authNavigation: 'AuthNavigation'}

where type is

 type NavigatorNamesType = {    homeNavigation: 'HomeNavigation',    authNavigation: 'AuthNavigation'}

all I want is to create another type which is like

type NewType={'HomeNavigation':undefined;'AuthNavigation':undefined;}

but this type should be dynamic in sense tenter code herehat if another key value is added in navigatorNames and NavigatorNamesTypes then NewType should automatically get update with that value as key and type as undefined.


Viewing all articles
Browse latest Browse all 6287

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>