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

How to make apply function like tailwind with typescript

$
0
0

if I have code like this

const AlignContent = {'content-start': {alignContent: 'flex-start'},'content-center': {alignContent: 'center'},'content-end': {alignContent: 'flex-end'},'content-stretch': {alignContent: 'stretch'},'content-between': {alignContent: 'space-between'},'content-around': {alignContent: 'space-around'},}const AlignItems = {'items-stretch': {alignItems: 'stretch'},'items-start': {alignItems: 'flex-start'},'items-center': {alignItems: 'center'},'items-end': {alignItems: 'flex-end'},'items-baseline': {alignItems: 'baseline'},}const styles = {    ...AlignContent,    ...AlignItems}function apply(styles: ??? ) {  //apply code here}

how to create interface ??? to be refer keyof typeof styles, so i want to called apply like this:

apply('items-stretch content-around')

note: ??? is not type string only, but i want to be suggested each from keyof typeof styles


Viewing all articles
Browse latest Browse all 6581

Latest Images

Trending Articles



Latest Images