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

fix(types): improve intellisense with colors #25347

Merged
merged 1 commit into from May 25, 2022
Merged

fix(types): improve intellisense with colors #25347

merged 1 commit into from May 25, 2022

Conversation

sean-perkins
Copy link
Contributor

Pull request checklist

Please check if your PR fulfills the following requirements:

  • Tests for the changes have been added (for bug fixes / features)
  • Docs have been reviewed and added / updated if needed (for bug fixes / features)
    • Some docs updates need to be made in the ionic-docs repo, in a separate PR. See the contributing guide for details.
  • Build (npm run build) was run locally and any changes were pushed
  • Lint (npm run lint) has passed locally and any fixes were made for failures

Pull request type

Please check the type of change your PR introduces:

  • Bugfix
  • Feature
  • Code style update (formatting, renaming)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • Documentation content changes
  • Other (please describe):

What is the current behavior?

Props that have a type of Colors, do not auto-complete with the list of available options. Instead they are replaced with a type of string.

Issue URL: N/A (internal)

What is the new behavior?

  • Modified Colors type to maintain the list of custom options along with a string literal

Does this introduce a breaking change?

  • Yes
  • No

Other information

Example of the toast controller with this change:

Screen Shot 2022-05-24 at 10 53 46 PM

Related to: #22151

Dev-build: 6.1.7-dev.11653446971.11d80e4c

@sean-perkins sean-perkins requested a review from a team as a code owner May 25, 2022 02:58
@github-actions github-actions bot added the package: core @ionic/core package label May 25, 2022
@liamdebeasi liamdebeasi requested review from amandaejohnston and removed request for a team May 25, 2022 13:10
@liamdebeasi
Copy link
Contributor

Are type guards something we need to be concerned about here? microsoft/TypeScript#29729 (comment)

Copy link
Contributor

@amandaejohnston amandaejohnston left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Works on my end 👍 I even get a nice Color | undefined type in the autocomplete, when before it was just string | undefined.
screenshot

@sean-perkins
Copy link
Contributor Author

@liamdebeasi I do not believe we take advantage of type guards in implementations with colors. I do not see any risk with this change, as the equivalent to the literal union not working in a situation that may be using type guards, would be equivalent to the existing behavior (no autocompletion/intellisense).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
package: core @ionic/core package
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants