Skip to content

Commit 5fc4611

Browse files
committed
Type fixes
1 parent 3fbb5c3 commit 5fc4611

File tree

5 files changed

+44
-20
lines changed

5 files changed

+44
-20
lines changed

@types/router/transition/hook-registry.d.ts

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,22 @@ export function matchState(
1616
criterion: any,
1717
transition: any,
1818
): boolean;
19-
/** Return a registration function of the requested type. */
19+
/**
20+
* Return a registration function of the requested type.
21+
* @param {ng.TransitionProvider| import("./transition.js").Transition} hookSource
22+
* @param {ng.TransitionProvider} transitionService
23+
* @param {import("./transition-event-type.js").TransitionEventType} eventType
24+
* @returns {( matchObject: any, callback: Function, options?: Record<string, any> ) => () => void }
25+
*/
2026
export function makeEvent(
21-
registry: any,
22-
transitionService: any,
23-
eventType: any,
24-
): (matchObject: any, callback: any, options?: {}) => any;
27+
hookSource: ng.TransitionProvider | import("./transition.js").Transition,
28+
transitionService: ng.TransitionProvider,
29+
eventType: import("./transition-event-type.js").TransitionEventType,
30+
): (
31+
matchObject: any,
32+
callback: Function,
33+
options?: Record<string, any>,
34+
) => () => void;
2535
/**
2636
* The registration data for a registered transition hook
2737
*/

@types/router/transition/transition.d.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,10 @@ export class Transition implements HookRegistry {
2929
* @type {import('../router.js').RouterProvider}
3030
*/
3131
_globals: import("../router.js").RouterProvider;
32-
_transitionService: import("./transition-service.js").TransitionProvider;
33-
_deferred: any;
32+
/** @type {ng.TransitionProvider} */
33+
_transitionProvider: ng.TransitionProvider;
34+
/** @type {PromiseWithResolvers<any>} */
35+
_deferred: PromiseWithResolvers<any>;
3436
/**
3537
* This promise is resolved or rejected based on the outcome of the Transition.
3638
*

src/router/transition/hook-builder.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ export class HookBuilder {
3232
* @returns
3333
*/
3434
buildHooksForPhase(phase) {
35-
return this.transition._transitionService
35+
return this.transition._transitionProvider
3636
._getEvents(phase)
3737
.map((type) => this.buildHooks(type))
3838
.reduce(unnestR, [])
@@ -93,7 +93,7 @@ export class HookBuilder {
9393
state,
9494
hook,
9595
_options,
96-
this.transition._transitionService._$exceptionHandler,
96+
this.transition._transitionProvider._$exceptionHandler,
9797
);
9898

9999
return { hook, node, transitionHook };
@@ -122,7 +122,7 @@ export class HookBuilder {
122122
const isCreate = hookType.hookPhase === TransitionHookPhase._CREATE;
123123

124124
// Instance and Global hook registries
125-
const $transitions = this.transition._transitionService;
125+
const $transitions = this.transition._transitionProvider;
126126

127127
const registries = isCreate
128128
? [$transitions]

src/router/transition/hook-registry.js

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -175,18 +175,24 @@ export class RegisteredHook {
175175
this._deregistered = true;
176176
}
177177
}
178-
/** Return a registration function of the requested type. */
179-
export function makeEvent(registry, transitionService, eventType) {
178+
/**
179+
* Return a registration function of the requested type.
180+
* @param {ng.TransitionProvider| import("./transition.js").Transition} hookSource
181+
* @param {ng.TransitionProvider} transitionService
182+
* @param {import("./transition-event-type.js").TransitionEventType} eventType
183+
* @returns {( matchObject: any, callback: Function, options?: Record<string, any> ) => () => void }
184+
*/
185+
export function makeEvent(hookSource, transitionService, eventType) {
180186
// Create the object which holds the registered transition hooks.
181-
const _registeredHooks = (registry._registeredHooks =
182-
registry._registeredHooks || {});
187+
const _registeredHooks = (hookSource._registeredHooks =
188+
hookSource._registeredHooks || {});
183189

184190
const hooks = (_registeredHooks[eventType.name] = []);
185191

186192
const removeHookFn = (x) => removeFrom(hooks, x);
187193

188194
// Create hook registration function on the HookRegistry for the event
189-
registry[eventType.name] = hookRegistrationFn;
195+
hookSource[eventType.name] = hookRegistrationFn;
190196
function hookRegistrationFn(matchObject, callback, options = {}) {
191197
const registeredHook = new RegisteredHook(
192198
transitionService,

src/router/transition/transition.js

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,11 @@ export class Transition {
5555
* @type {import('../router.js').RouterProvider}
5656
*/
5757
this._globals = globals;
58-
this._transitionService = transitionService;
58+
59+
/** @type {ng.TransitionProvider} */
60+
this._transitionProvider = transitionService;
61+
62+
/** @type {PromiseWithResolvers<any>} */
5963
this._deferred = Promise.withResolvers();
6064

6165
/**
@@ -111,10 +115,12 @@ export class Transition {
111115
* (which can then be used to register hooks)
112116
*/
113117
createTransitionHookRegFns() {
114-
this._transitionService
118+
this._transitionProvider
115119
._getEvents()
116120
.filter((type) => type.hookPhase !== TransitionHookPhase._CREATE)
117-
.forEach((type) => makeEvent(this, this._transitionService, type));
121+
.forEach((type) => {
122+
return makeEvent(this, this._transitionProvider, type);
123+
});
118124
}
119125

120126
getHooks(hookName) {
@@ -125,7 +131,7 @@ export class Transition {
125131
const enteringStates = this._treeChanges.entering.map((node) => node.state);
126132

127133
PathUtils.applyViewConfigs(
128-
this._transitionService.$view,
134+
this._transitionProvider.$view,
129135
this._treeChanges.to,
130136
enteringStates,
131137
);
@@ -445,7 +451,7 @@ export class Transition {
445451
);
446452

447453
targetState = targetState.withOptions(newOptions, true);
448-
const newTransition = this._transitionService.create(
454+
const newTransition = this._transitionProvider.create(
449455
this._treeChanges.from,
450456
targetState,
451457
);

0 commit comments

Comments
 (0)