Skip to content
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

Merged

Conversation

weltenwort
Copy link
Member

@weltenwort weltenwort commented Mar 20, 2019

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 in dist/ 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 mobile
  • This was checked in IE11
  • This was checked in dark mode
  • Any props added have proper autodocs
  • Documentation examples were added
  • A changelog entry exists and is marked appropriately
  • This was checked for breaking changes and labeled appropriately
  • Jest tests were updated or added to match the most common scenarios
  • This was checked against keyboard-only and screenreader scenarios
  • This required updates to Framer X components

@weltenwort weltenwort self-assigned this Mar 20, 2019
@weltenwort weltenwort force-pushed the enhancement-export-theme-ts-types branch from 72a71e0 to 22686c9 Compare March 20, 2019 19:15
@weltenwort weltenwort marked this pull request as ready for review March 20, 2019 19:34
@weltenwort
Copy link
Member Author

/cc @mattapperson @sqren

Copy link
Member

@sorenlouv sorenlouv left a 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! 👍👍👍

Copy link
Contributor

@chandlerprall chandlerprall left a 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.

@weltenwort weltenwort merged commit a4c3eb7 into elastic:master Mar 21, 2019
weltenwort added a commit to weltenwort/eui that referenced this pull request Mar 21, 2019
weltenwort added a commit that referenced this pull request Mar 21, 2019
This fixes an incorrect merge conflict resolution in the changelog of #1750.
weltenwort added a commit to weltenwort/kibana that referenced this pull request Apr 1, 2019
…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.
weltenwort added a commit to elastic/kibana that referenced this pull request Apr 1, 2019
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.
weltenwort added a commit to weltenwort/kibana that referenced this pull request Apr 2, 2019
…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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants