-
Notifications
You must be signed in to change notification settings - Fork 296
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
DTS Bundling not exporting previously available interfaces and types #1115
Comments
Hi @AndrewLeedham, this looks like a quirk of the TypeScript compiler. We wouldn't want to expose APIs that we'd like to reserve the right to change in the future. However, you can work around this using the const focus = {
'&:focus-visible': {
color: 'blue'
}
} satisfies StyleRule['selectors']; Does this work for you? I realise this is just an example and might not be the same as your production code. |
@mrm007 thanks for the workaround. You are right this is a minimal repro. The actual use case is using helper functions which return those objects. I could probably use satisfies and infer return types, but this seems like quite a significant gotcha. Composing types at least in our codebase is very common, and we are not yet on TS 5 (although I will work on upgrading soon). Perhaps I exported too much, I was just concious that other functions may have similiar issues. But I could just export |
@mrm007 another case where keeping raw typing around doesn't quite work is conditionally modifying a styles object: TS Playground Link I updated the original PR to just export |
Not sure what the const selectors = {
'a': {
color,
}
// Keeps the type as narrow as possible
} satisfies StyleRule['selectors'];
if (color) {
// selectors is not a StyleRule['selectors'], so it doesn't know about the `a:hover` property
selectors['a:hover'] = {
color: hoverColor
}
} By using an explicit type annotation, you can conditionally mutate the |
Describe the bug
Since
@vanilla-extract/[email protected]
I cannot compile Vanilla Extract types with tsc. The issue seem to step from the bundling of dts files, as interfaces likeAllQueries
are no longer exported, so the TypeScript compiler throws the following error:This happens when composing types like
StyleRule
which are exported but use interfaces that aren't.Reproduction
https://www.typescriptlang.org/play?ts=5.1.3#code/JYWwDg9gTgLgBAbzgZRgTwDYFMBKBXbOAXzgDMoIQ4ByAAQDcBDAO2Aw0YFosAPGKRgGMYAekEBncdQDcAKFmhIsRHChZBwMFmJkKVOk1bsuvfkNFqNWqXNmCIzcfFIRBecQC4U6bPmwBtanEsbGFoKQBdOABeRFk4GgAyDxc3cU56YHFgACNsai8EeIS4ewxoL2o8vCxqYqJZBtleJXh7R3heRnBfdU1tWMt+gAoihJzGYMLihLKKmjUAE2oAGnq1hKYoYBYYTziSuEWssA40acPx8sEAawvLhOPxU8ZzmjzXG9WZkqINy+owGYGCBWE4H1uBQODyOJzOlSBIOYYIhXx+CT+6LIrnc9wewVCMHCeJhADpyal3P8Hg0aT9MRjGgBKaRAA
System Info
Used Package Manager
yarn
Logs
Validations
The text was updated successfully, but these errors were encountered: