Skip to content

Commit 910f3a8

Browse files
committed
docs(skills): implementations implement their contract [skip ci]
A contract holds only abstract members; extends is for one that carries shared code.
1 parent 313f1c6 commit 910f3a8

2 files changed

Lines changed: 6 additions & 1 deletion

File tree

‎.agents/skills/cli-dependency-injection/SKILL.md‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,10 @@ same instance, so a class may mix them for as long as it needs to.
2020
- A new service declares `@Contract()` in `lib/contracts/internal/`, with no name, an
2121
implementation called `*Impl`, and a lazy registration in the bootstrap:
2222
`injector.register(provideLazy(Thing, () => require("./path").ThingImpl))`.
23+
- An implementation `implements` its contract. A contract holds only abstract members,
24+
so there is nothing to inherit, and the class stays free to extend its own base.
25+
`extends` is for a contract that carries shared code; adding code to a contract is a
26+
decision to ask about. A test stub may extend one.
2327
- A value that is not a class takes an `InjectionToken`; give it a `factory` if it can
2428
provide itself.
2529
- Do not bundle services into one object that is passed around.

‎.agents/skills/cli-dependency-injection/references/giving-a-service-a-contract.md‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,8 @@ effects, so it never imports `lib/common/yok` or an implementation.
6161
declaration file. A `.d.ts` without any `import` or `export` is ambient, and
6262
the import turns it into a module: wrap **everything** in it in
6363
`declare global { … }`, as `lib/definitions/prompter.d.ts` does.
64-
3. Rename the class to `ThingImpl implements Thing` and fix imports of the class,
64+
3. Rename the class to `ThingImpl implements Thing` (not `extends`; see the skill) and
65+
fix imports of the class,
6566
tests included. A class with `@performanceLog` methods keeps its name: the
6667
decorator reports it. The old class export disappears for deep `require()`s;
6768
say so in the pull request.

0 commit comments

Comments
 (0)