-
Notifications
You must be signed in to change notification settings - Fork 11
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Types not working correctly #20
Comments
Second issue related to types, in the compound variant it's not happy variants: {
color: {
red: {
backgroundColor: theme.colors.red500, // ✅ all good here
}
}
},
compoundVariants: [
{
color: 'red',
variant: 'solid',
css: {
backgroundColor: theme.colors.red500, // ❌ TS error here
},
},
] TS error:
But if I use |
Using the shortcut for theme token with const Heading = styled(TextComponent, {
fontFamily: '$inter', // ✅
fontWeight: '$700', // ❌
}) const Heading = styled(TextComponent, {
fontFamily: '$inter', // ✅
fontWeight: theme.fontWeights[700], // ✅
}) |
Another issue, negative token values don't seem to work they are treated as positive. const View = styled('View');
<View css={{ marginLeft: '$2' }}>
<View css={{ marginLeft: '-$2' }}> They both have the same output |
This issue should be fixed in the latest canary version. I had a typo in the default theme map which caused |
This should be now fixed in |
This is related to the currently unsolved issue of having all I would love to fix this but it's quite complicated since the types are so complex 😅 |
@mtt87 I followed your instructions and everything works just fine for me 😅 Maybe you have misconfigured the Stitches config? Here's the config I used for testing: export const { styled, theme } = createStitches({
theme: {
colors: {
// Palette
blue100: '#ab9cf7',
blue500: '#301b96',
blue900: '#0D0630',
black: '#222',
white: '#fff',
primary: '$blue500',
primaryDark: '$blue900',
primaryLight: '$blue100',
secondary: '#8BBEB2',
secondaryDark: '#384d48',
secondaryLight: '#d9fff6',
background: '$white',
text: '$black',
},
space: {
1: 4,
2: 8,
3: 16,
4: 24,
5: 32,
6: 40,
7: 56,
8: 72,
9: 96,
},
sizes: {
hairlineWidth: StyleSheet.hairlineWidth,
},
radii: {
sm: 4,
md: 8,
lg: 24,
full: 999,
},
},
utils: {
size: (value: number) => ({
width: value,
height: value,
}),
flexCenter: (value?: Stitches.PropertyValue<'flexDirection'>) => ({
flexDirection: value || 'row',
justifyContent: 'center',
alignItems: 'center',
}),
absoluteFill: () => ({
...StyleSheet.absoluteFillObject,
}),
},
}); |
That's interesting 🤔 Could you try with my repo https://github.com/mtt87/debug-stitches-native-typescript ? Can you also double check what typescript are you using? Thank you! |
Okay now I'm getting the typing issue when I changed the TypeScript version. I think my example app was using the TypeScript of the Now I just need to figure out why on earth the types are not working properly 😭 |
@mtt87 I think I found the source of the TS bug 🐛🕵🏻♂️ The typings for About all the remaining TS problems that have been commented under this issue: it would be better to move them to separate issues so that they can be tackled one by one more easily (and nothing gets lost in the sea of comments). |
EDIT: sorry I accidentally pressed enter and created the empty issue 😆
First of all thanks for creating this library, I'm testing it and I found this issue where types are not working.

It should suggest
fontFamily
,fontSize
etc but it's notThat said, once I write

fontFamily: "
then I get the correct autocomplete based on my tokens.EDIT: I just realised I can also do this but still the issue is there
The text was updated successfully, but these errors were encountered: