Skip to content

Commit 132fe87

Browse files
committed
refactor(di): drop the names of the injector facade contracts
CommandRegistry, ModuleRegistry and PublicApiBuilder were never registered under a string, are not exported from nativescript/contracts, and are resolved by class everywhere.
1 parent aa74307 commit 132fe87

4 files changed

Lines changed: 7 additions & 7 deletions

File tree

‎lib/common/contracts/command-registry.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { LegacyContract } from "../di/contract";
1+
import { Contract } from "../di/contract";
22
import { InjectionToken } from "../di/injection-token";
33
import type { ICommand } from "../definitions/commands";
44

@@ -84,7 +84,7 @@ export type DeferredCommandResult =
8484
* facade later is a provider swap for this token, not a consumer migration.
8585
* Members slated for replacement keep their deprecation markers.
8686
*/
87-
@LegacyContract({ name: "commandRegistry" })
87+
@Contract()
8888
export abstract class CommandRegistry {
8989
/**
9090
* @deprecated Path-based command registration; use registerDeferredCommand,

‎lib/common/contracts/module-registry.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
import { LegacyContract } from "../di/contract";
1+
import { Contract } from "../di/contract";
22

33
/**
44
* @deprecated The lazy module-loader face of the injector facade — the
55
* require-time path map. Wholly replaced by provideLazy(); this contract
66
* exists so its remaining consumers are typed against exactly what they use
77
* until the bootstrap migrates.
88
*/
9-
@LegacyContract({ name: "moduleRegistry" })
9+
@Contract()
1010
export abstract class ModuleRegistry {
1111
abstract require(names: string | string[], file: string): void;
1212
abstract overrideAlreadyRequiredModule: boolean;

‎lib/common/contracts/public-api-builder.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
import { LegacyContract } from "../di/contract";
1+
import { Contract } from "../di/contract";
22

33
/**
44
* The public-API-builder face of the injector facade: the machinery behind
55
* `require('nativescript')`. Bound by the compatibility constraints of the
66
* published library surface; do not add new entries through it.
77
*/
8-
@LegacyContract({ name: "publicApiBuilder" })
8+
@Contract()
99
export abstract class PublicApiBuilder {
1010
abstract requirePublic(names: string | string[], file: string): void;
1111
abstract requirePublicClass(names: string | string[], file: string): void;

‎test/compat/injector-facade-surface.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ describe("injector facade surface", () => {
104104
for (const token of [CommandRegistry, ModuleRegistry, PublicApiBuilder]) {
105105
assert.strictEqual(inj.get(<any>token), inj);
106106
}
107-
assert.strictEqual(inj.resolve("commandRegistry"), inj);
107+
assert.isFalse(inj.has("commandRegistry"));
108108

109109
runInInjectionContext(inj, () => {
110110
assert.strictEqual(inject(CommandRegistry), inj);

0 commit comments

Comments
 (0)