nandorojo / dripsy

🍷 Responsive, unstyled UI primitives for React Native + Web.
https://dripsy.xyz
MIT License
1.99k stars 77 forks source link

Getting TypeScript error in fontWeights for makeTheme() #217

Closed Stukz closed 2 years ago

Stukz commented 2 years ago

Error

Steps to Reproduce

  1. npx react-native init MyApp --template react-native-template-typescript
  2. cd MyApp
  3. yarn add dripsy
  4. inside the App.tsx import { makeTheme } from 'dripsy';
  5. on line 31 add
    
    ...
    const weights = {
    custom: 'bold',
    };

const theme = makeTheme({ fontWeights: { ...weights, }, });


## Extra Info
<img width="390" alt="image" src="https://user-images.githubusercontent.com/57040392/175137617-fb02b88d-5519-4449-b513-75fd927348a8.png">
nandorojo commented 2 years ago

what if you do this:

const weights = {
  custom: 'bold',
} as const 

I now see that it’s because fontWeight requires that the values be specific strings.

You could also put ‘bold’ as const

Stukz commented 2 years ago

I just found this solution doing some research about Function.Narrow, I didn't notice this response before but thanks for it!