Skip to content

docs(skills): describe ControllerClass typing and the Controller-only route rule - #106

Merged
Upd4ting merged 1 commit into
mainfrom
docs/ant-1813
Nov 10, 2026
Merged

Upd4ting merged 1 commit into
mainfrom
docs/ant-1813

Conversation

@Upd4ting

Copy link
Copy Markdown
Member

Why

Module authors and agents who write a controller from the api-interface skill alone should see two breaking changes. #68 typed ControllerClass, and #67 made a route decorator outside a Controller class throw. docs/2.controllers.md and UPGRADING.md cover both. The skill, which ships through antelopeJs.skills, named neither.

What

  • skills/api-interface/SKILL.md now says the following. Controller(location) returns a ControllerClass<object>, so a bare instance has no string index. Controller(location, Base) returns a ControllerClass<Base> that types the instances, with an example. Route decorators apply only to classes built by Controller, PartialController or extend, and to their subclasses. Any other class throws TypeError: Route decorators apply to Controller classes; <name> has no location when it is defined.
  • skills/api-interface/cases.json gains api-interface-route-on-plain-class, an eval case built on that TypeError.

Skill files only. No TSDoc or docs/ change, so this PR does not overlap ANT-1812.

Proof

The code that enforces the documented rules:

  • src/controller.ts:276-289. The Controller overloads return ControllerClass<object> without a base and ControllerClass<T> with base: Class<T>. ControllerClass<T = object> is declared at src/controller.ts:9.
  • src/routes.ts:131-136. ProcessCallback, which every route decorator calls, throws the TypeError when isControllerClass(target.constructor) is false.
  • src/controller.ts:301-307. isControllerClass requires the static location and extend that Controller and extend assign. Subclasses inherit both.
  • Tests: src/tests/route-decorators.test.ts:91-97 (refuse a method of a class that Controller did not create) and src/tests/controller-class-default.test.ts:10-17 (names no string index on a bare ControllerClass instance).

I type-checked the skill's new example in a scratch file under src/ with pnpm exec tsc --noEmit -p ., then deleted the file. StoreController compiled. A Controller("/bare") subclass that read this.books failed as the skill says:

src/zz-snippet.ts(14,17): error TS2339: Property 'books' does not exist on type 'Bare'.

pnpm run checks at 70acc3d:

> @antelopejs/interface-api@0.3.1 checks /home/debian/.t3/worktrees/interface-api/docs-ant-1813
> antelopejs-checks
Checks: 9 passed, 0 failed.

@Upd4ting
Upd4ting merged commit ac26a6c into main Nov 10, 2026
7 checks passed
@Upd4ting
Upd4ting deleted the docs/ant-1813 branch November 10, 2026 15:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant