Skip to content

Commit 5c47e6d

Browse files
committed
Add instructions around MutableDisposables and const enums
1 parent 5ef4f86 commit 5c47e6d

1 file changed

Lines changed: 7 additions & 0 deletions

File tree

AGENTS.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,13 @@ export class MyAddon implements ITerminalAddon {
5757
- Proposed APIs require `allowProposedApi: true` option
5858
- Constructor-only options (cols, rows) cannot be changed after instantiation
5959

60+
**Disposable Management**:
61+
- When a disposable object can be replaced over time, prefer a registered `MutableDisposable` over manual dispose/reassign logic.
62+
- Register it on the owning class (for example, `this._register(new MutableDisposable())`) and assign through `.value`; this automatically disposes the previous value and avoids accidentally leaking resources.
63+
64+
**TypeScript Constants**:
65+
- Prefer `const enum` over top-level `const` declarations for primitive constants when appropriate, since values are inlined and avoid runtime property lookups.
66+
6067
**Testing Utilities**: Use `TestUtils.ts` helpers:
6168
- `openTerminal(ctx, options)` for setup
6269
- `pollFor(page, fn, expectedValue)` for async assertions

0 commit comments

Comments
 (0)