-
Notifications
You must be signed in to change notification settings - Fork 841
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
Emit TypeScript type definitions for variables extracted from themes #1750
Emit TypeScript type definitions for variables extracted from themes #1750
Conversation
72a71e0
to
22686c9
Compare
/cc @mattapperson @sqren |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So much awesome! Thanks! 👍👍👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is beautiful. Pulled code and ran locally, confirmed output type files are named correctly and export the expected types.
This adds a specialization of the styled-components api, which is correctly typed according to the new theme variable type definitions included in EUI (elastic/eui#1750) and made available in Kibana via #33873.
…c#33607) This adds a specialization of the styled-components api, which is correctly typed according to the new theme variable type definitions included in EUI (elastic/eui#1750) and made available in Kibana via elastic#33873.
Summary
This enhances the
compile-scss.js
build script to also emit TypeScript type definitions for the JSON files generated from the theme variables. These type definitions are stored as.json.d.ts
files indist/
alongside the JSON files so the imports are typed correctly.When imported in downstream projects like Kibana, the imported symbols will be typed appropriately, which would reduce the risk involved in making breaking changes to these variables like #1590 did.
Letting the TypeScript compiler derive the types automatically was attempted twice in Kibana (elastic/kibana#24425 and elastic/kibana#25516). Both attempts failed due to limitations Kibana's build process and the TypeScript compiler.
Checklist
This was checked in mobileThis was checked in IE11This was checked in dark modeAny props added have proper autodocsDocumentation examples were addedJest tests were updated or added to match the most common scenariosThis was checked against keyboard-only and screenreader scenariosThis required updates to Framer X components