Skip to content

Commit 7582a9f

Browse files
committed
moves the route manager types up a level to avoid the nonsense the type test causes
1 parent 68781db commit 7582a9f

10 files changed

Lines changed: 471 additions & 420 deletions

File tree

packages/@ember/-internals/routing/route-managers/api.ts

Lines changed: 25 additions & 388 deletions
Large diffs are not rendered by default.

packages/@ember/routing/route.ts

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ import type { RouteManager, RouteStateBucket } from '@ember/-internals/routing/r
3131
import { hasClassicInterop } from '@ember/-internals/routing/route-managers/api';
3232
import type { InternalRouteInfo, Route as IRoute, Transition, TransitionState } from 'router_js';
3333
import { PARAMS_SYMBOL, STATE_SYMBOL } from 'router_js';
34-
import type { QueryParam, default as EmberRouter } from '@ember/routing/router';
34+
import type { default as EmberRouter } from '@ember/routing/router';
3535
import { default as generateController } from './lib/generate_controller';
3636
import type { ExpandedControllerQueryParam, NamedRouteArgs } from './lib/utils';
3737
import {
@@ -45,6 +45,23 @@ export interface ExtendedInternalRouteInfo<R extends Route> extends InternalRout
4545
_names?: unknown[];
4646
}
4747

48+
export interface QueryParam {
49+
prop: string;
50+
urlKey: string;
51+
type: string;
52+
route: Route;
53+
parts?: string[];
54+
// eslint-disable-next-line @typescript-eslint/no-empty-object-type
55+
values: {} | null;
56+
scopedPropertyName: string;
57+
scope: string;
58+
defaultValue: unknown;
59+
undecoratedDefaultValue: unknown;
60+
serializedValue: string | null | undefined;
61+
serializedDefaultValue: string | null | undefined;
62+
controllerName: string;
63+
}
64+
4865
export type QueryParamMeta = {
4966
qps: QueryParam[];
5067
map: Record<string, QueryParam>;

packages/@ember/routing/router.ts

Lines changed: 8 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ import { Promise as RSVPPromise } from 'rsvp';
4444
import { DEBUG } from '@glimmer/env';
4545
import {
4646
type default as Route,
47+
type QueryParam,
4748
type QueryParamMeta,
4849
defaultSerialize,
4950
getFullQueryParams,
@@ -119,22 +120,10 @@ if (DEBUG) {
119120
};
120121
}
121122

122-
export interface QueryParam {
123-
prop: string;
124-
urlKey: string;
125-
type: string;
126-
route: Route;
127-
parts?: string[];
128-
// eslint-disable-next-line @typescript-eslint/no-empty-object-type
129-
values: {} | null;
130-
scopedPropertyName: string;
131-
scope: string;
132-
defaultValue: unknown;
133-
undecoratedDefaultValue: unknown;
134-
serializedValue: string | null | undefined;
135-
serializedDefaultValue: string | null | undefined;
136-
controllerName: string;
137-
}
123+
// `QueryParam` now lives in `@ember/routing/route`. It was historically
124+
// exported from `@ember/routing/router`, so re-export it here to preserve that
125+
// published deep-import path.
126+
export type { QueryParam };
138127

139128
function K(this: Router<Route>) {
140129
return this;
@@ -1497,7 +1486,9 @@ class EmberRouter extends EmberObject.extend(Evented) implements Evented {
14971486
if (!hasClassicInterop(manager)) {
14981487
return undefined;
14991488
}
1500-
return manager.qp(route.bucket);
1489+
// The manager contract types `qp()` as `unknown`. Having
1490+
// confirmed classic interop, narrow it to the concrete type.
1491+
return manager.qp(route.bucket) as QueryParamMeta;
15011492
}
15021493

15031494
/**

packages/router_js/index.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,23 @@ export {
2323
isTransitionAborted,
2424
type TransitionAbortedError,
2525
} from './lib/transition-aborted-error';
26+
27+
export { routeCapabilities, hasClassicInterop } from './lib/route-manager';
28+
export type {
29+
RouteManager,
30+
RouteManagerWithClassicInterop,
31+
RouteStateBucket,
32+
RouteCapabilities,
33+
RouteCapabilitiesVersions,
34+
NavigationState,
35+
NavigationActions,
36+
AsyncNavigationState,
37+
ClassicInteropArgs,
38+
WillEnterState,
39+
EnterState,
40+
DidEnterState,
41+
WillExitState,
42+
ExitState,
43+
DidExitState,
44+
CreateRouteArgs,
45+
} from './lib/route-manager';

packages/router_js/lib/route-info.ts

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,8 @@ import type InternalTransition from './transition';
88
import { isTransition, PARAMS_SYMBOL, QUERY_PARAMS_SYMBOL, STATE_SYMBOL } from './transition';
99
import { isParam, isPromise, merge } from './utils';
1010
import { throwIfAborted } from './transition-aborted-error';
11-
import type {
12-
EnterState,
13-
RouteManager,
14-
RouteStateBucket,
15-
WillEnterState,
16-
} from '@ember/-internals/routing/route-managers/api';
17-
import { hasClassicInterop } from '@ember/-internals/routing/route-managers/api';
11+
import type { EnterState, RouteManager, RouteStateBucket, WillEnterState } from './route-manager';
12+
import { hasClassicInterop } from './route-manager';
1813

1914
export type IModel = {} & {
2015
id?: string | number;

0 commit comments

Comments
 (0)