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: abstract injection token creation #56

Merged
merged 1 commit into from
Nov 20, 2023

Conversation

nartc
Copy link
Contributor

@nartc nartc commented Nov 17, 2023

This PR adds createInjectionToken function to abstract the way we create InjectionToken

  • InjectFn is strongly-typed and has overloads to properly support {optional: true}
  • ProvideFn is strongly-typed version of {provide, useValue}
  • ProvideFnExisting is strongly-typed version of {provide, useExisting}
  • TOKEN is exposed for more manual use-cases

PR Checklist

Please check if your PR fulfills the following requirements:

PR Type

What kind of change does this PR introduce?

  • Bugfix
  • Feature
  • Code style update (formatting, local variables)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • CI related changes
  • Documentation content changes
  • Other... Please describe:

Which package are you modifying?

  • accordion
  • alert
  • alert-dialog
  • aspect-ratio
  • avatar
  • badge
  • button
  • calendar
  • card
  • checkbox
  • collapsible
  • combobox
  • command
  • context-menu
  • data-table
  • date-picker
  • dialog
  • dropdown-menu
  • hover-card
  • input
  • label
  • menubar
  • navigation-menu
  • popover
  • progress
  • radio-group
  • scroll-area
  • select
  • separator
  • sheet
  • skeleton
  • slider
  • switch
  • table
  • tabs
  • textarea
  • toast
  • toggle
  • tooltip
  • typography

What is the current behavior?

Currently, the InjectionToken inside of ui-core is created manually, and the exposed inject***() does not support { optional: true } properly, leading to various places using Optional Chaining unnecessarily.

Closes #

What is the new behavior?

InjectionToken is created with createInjectionToken

Does this PR introduce a breaking change?

  • Yes
  • No

Other information

This PR adds `createInjectionToken` function to abstract the way we create `InjectionToken`

- `InjectFn` is strongly-typed and has overloads to properly support `{optional: true}`
- `ProvideFn` is strongly-typed version of `{provide, useValue}`
- `ProvideFnExisting` is strongly-typed version of `{provide, useExisting}`
- `TOKEN` is exposed for more manual use-cases
Copy link

vercel bot commented Nov 17, 2023

Someone is attempting to deploy a commit to a Personal Account owned by @goetzrobin on Vercel.

@goetzrobin first needs to authorize it.

Copy link
Collaborator

@goetzrobin goetzrobin left a comment

Choose a reason for hiding this comment

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

Let me know what you think about my comment and if we should explicitly require the brn part (e.g. throw an error) or if this is actually already covered by your changes and I am just missing it

@goetzrobin goetzrobin merged commit 5b81a04 into spartan-ng:main Nov 20, 2023
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants