Skip to content

Commit ec5de90

Browse files
committed
refactor(yok): type the di bridge on IInjector
The token container was reachable only through a getter on the concrete Yok class, so every crossing from facade-typed code into the new API needed an any cast - the migration's most important seam was invisible to the type system. IInjector now declares readonly di: Injector.
1 parent 9bc9739 commit ec5de90

2 files changed

Lines changed: 9 additions & 1 deletion

File tree

lib/common/definitions/yok.d.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { IDisposable, IDictionary } from "../declarations";
22
import { ICommand } from "./commands";
33
import { IKeyCommand, IValidKeyName } from "./key-commands";
4+
import { Injector } from "../di/injector";
45

56
/**
67
* The legacy injector facade surface. Every member is individually
@@ -9,6 +10,13 @@ import { IKeyCommand, IValidKeyName } from "./key-commands";
910
* completes.
1011
*/
1112
interface IInjector extends IDisposable {
13+
/**
14+
* The token-based container backing this facade — the bridge to the
15+
* new-style API. Registrations and lookups by token go here; code already
16+
* running in an injection context should prefer inject(Injector).
17+
*/
18+
readonly di: Injector;
19+
1220
/**
1321
* @deprecated Use provideLazy() from lib/common/di — the same deferred
1422
* loading, token-based.

test/compat/legacy-hooks.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,7 @@ describe("legacy hook contract", () => {
283283
});
284284

285285
assert.strictEqual(capture.logger, testInjector.resolve("logger"));
286-
assert.strictEqual(capture.container, (<any>testInjector).di);
286+
assert.strictEqual(capture.container, testInjector.di);
287287
assert.strictEqual(capture.hookArgs, payload);
288288
});
289289

0 commit comments

Comments
 (0)