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

Trying to dynamically set interface based off of enum value

$
0
0

Hey all I'm trying to dynamically set a style interface to a type like this:

type IListStyles = {    [LIST_TYPE.ADD_ACTIONABLE]: IListItemAddActionableStyle;    [LIST_TYPE.SUPERVALUE]: IListItemSupervalueStyle;}enum LIST_TYPE {  ADD_ACTIONABLE = "ADD_ACTIONABLE",  SUPERVALUE = "SUPERVALUE",}export interface IListItem<T extends LIST_TYPE> {  style?: IListStyles[T];  type: T;

Buuut I'm getting that T can't be used to index IListStyles has anyone done something like this before?


Viewing all articles
Browse latest Browse all 6214

Trending Articles



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