Type issue when using themes #292
-
Version: "@vanilla-extract/css": "1.2.3" Hi All, Just playing around with this over the weekend and I am running into this interesting type error when trying to use one of the examples from the site: export const contract = createThemeContract({
color: {
brand: null
},
font: {
body: null
}
});
export const themeA = createTheme(contract, {
color: {
brand: 'blue'
},
font: {
body: 'arial'
}
});
export const themeB = createTheme(contract, {
color: {
brand: 'pink'
},
font: {
body: 'comic sans ms'
}
});
export const className = style({
backgroundColor: contract.color.brand,
color: contract.color.brand
}); It seems that typescript is complaining about the This is the error:
It seems the culprit here is the existence of Thanks for your help in advance :) Adam |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 4 replies
-
I tried this locally but couldn't reproduce it. Would you be able to reproduce this on CodeSandbox? |
Beta Was this translation helpful? Give feedback.
-
Any updates on this? Is there anything else you need from me for debugging ? |
Beta Was this translation helpful? Give feedback.
-
OK this was a strange one. It seems that using Either way though you have two options:
|
Beta Was this translation helpful? Give feedback.
OK this was a strange one. It seems that using
createThemeContract
withnull
values doesn't work when strictNullChecks is not enabled. We may consider updating some examples to avoid this confusion.Either way though you have two options:
strictNullChecks
orstrict
in yourtsconfig.json
null
, use a string value e.g.