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

[BUGFIX stable] Allow store to be injected on Route #20482

Merged
merged 1 commit into from
Jun 29, 2023

Conversation

chriskrycho
Copy link
Contributor

In the public types, TypeScript (correctly) complains when users try to inject the store with @service store on a Route subclass, because the item is an accessor on Route itself, and the service injection "happens" to work only because the set store(value) smashes itself as well as the corresponding get store() using defineProperty.

Work around this by renaming the getter in question to _store and updating the one usage to check for a store property before falling back to the _store property. Happily, this also dovetails with the plan to deprecate the automatic findModel behavior this exists to support: once that is removed, this entire code path can be cleaned up trivially.

@chriskrycho chriskrycho added Bug TypeScript Work on Ember’s types labels Jun 28, 2023
tests/docs/expected.js Outdated Show resolved Hide resolved
In the public types, TypeScript (correctly) complains when users try to
inject the store with `@service store` on a `Route` subclass, because
the item is an accessor on `Route` itself, and the service injection
"happens" to work only because the `set store(value)` smashes itself as
well as the corresponding `get store()` using `defineProperty`.

Work around this by renaming the getter in question to `_store` and
updating the one usage to check for a `store` property before falling
back to the `_store` property. Happily, this also dovetails with the
plan to deprecate the automatic `findModel` behavior this exists to
support: once that is removed, this entire code path can be cleaned up
trivially.
@chriskrycho chriskrycho merged commit ad0a568 into main Jun 29, 2023
18 checks passed
@chriskrycho chriskrycho deleted the types/router-store-fix branch June 29, 2023 03:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug TypeScript Work on Ember’s types
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants