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

[CLEANUP] Remove deprecated auto-location #20406

Merged
merged 1 commit into from
Mar 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 19 additions & 10 deletions packages/@ember/-internals/owner/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,19 +72,28 @@ export type FullName<
@private
*/
// eslint-disable-next-line @typescript-eslint/no-empty-interface
export interface DIRegistry extends Record<string, Record<string, unknown>> {}
export interface DIRegistry {}

// Convenience utility for pulling a specific factory manager off `DIRegistry`
// if one exists, or falling back to the default definition otherwise.
/**
@private
*/
type ResolveFactoryManager<
Type extends string,
Name extends string
> = DIRegistry[Type][Name] extends infer RegistryEntry extends object
? FactoryManager<RegistryEntry>
: FactoryManager<object> | undefined;
type ResolveFactoryManager<Type extends string, Name extends string> = Type extends ValidType
? Name extends ValidName<Type>
? DIRegistry[Type][Name] extends infer RegistryEntry extends object
? FactoryManager<RegistryEntry>
: FactoryManagerDefault
: FactoryManagerDefault
: FactoryManagerDefault;

type FactoryManagerDefault = FactoryManager<object> | undefined;

type Lookup<Type extends string, Name extends string> = Type extends ValidType
? Name extends ValidName<Type>
? DIRegistry[Type][Name]
: unknown
: unknown;

/**
The common interface for the ability to `register()` an item, shared by the
Expand Down Expand Up @@ -230,10 +239,10 @@ interface BasicContainer {
@param {RegisterOptions} options
@return {any}
*/
lookup<Type extends ValidType, Name extends ValidName<Type>>(
lookup<Type extends string, Name extends string>(
fullName: FullName<Type, Name>,
options?: RegisterOptions
): DIRegistry[Type][Name];
): Lookup<Type, Name>;

/**
Given a `FullName`, of the form `"type:name"` return a `FactoryManager`.
Expand Down Expand Up @@ -277,7 +286,7 @@ interface BasicContainer {
@param {string} fullName
@return {FactoryManager}
*/
factoryFor<Type extends ValidType, Name extends ValidName<Type>>(
factoryFor<Type extends string, Name extends string>(
fullName: FullName<Type, Name>
): ResolveFactoryManager<Type, Name>;
}
Expand Down
2 changes: 1 addition & 1 deletion packages/@ember/-internals/owner/type-tests/owner.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ owner.lookup('non-namespace-string');
expectTypeOf(owner.lookup('namespace@type:name')).toEqualTypeOf<unknown>();

// Arbitrary registration patterns work, as here.
declare module '@ember/-internals/owner' {
declare module '@ember/owner' {
export interface DIRegistry {
etc: {
'my-type-test': ConstructThis;
Expand Down
2 changes: 0 additions & 2 deletions packages/@ember/application/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import { RSVP } from '@ember/-internals/runtime';
import { EventDispatcher } from '@ember/-internals/views';
import Route from '@ember/routing/route';
import Router from '@ember/routing/router';
import AutoLocation from '@ember/routing/auto-location';
import HashLocation from '@ember/routing/hash-location';
import HistoryLocation from '@ember/routing/history-location';
import NoneLocation from '@ember/routing/none-location';
Expand Down Expand Up @@ -1205,7 +1204,6 @@ function commonSetupRegistry(registry: Registry) {
registry.register('route:basic', Route);
registry.register('event_dispatcher:main', EventDispatcher);

registry.register('location:auto', AutoLocation);
registry.register('location:hash', HashLocation);
registry.register('location:history', HistoryLocation);
registry.register('location:none', NoneLocation);
Expand Down
1 change: 0 additions & 1 deletion packages/@ember/application/tests/application_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,6 @@ moduleFor(
verifyRegistration(assert, application, 'route:basic');
verifyRegistration(assert, application, 'event_dispatcher:main');

verifyRegistration(assert, application, 'location:auto');
verifyRegistration(assert, application, 'location:hash');
verifyRegistration(assert, application, 'location:history');
verifyRegistration(assert, application, 'location:none');
Expand Down
Loading