You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Lock the type surface with access modifiers and honest nullability
The migration exposed every component internal as public. Consumers could
reach `_config`, `_element`, and helper methods, which would make them
breaking changes once shipped. Restrict the surface and stop a few types from
lying about nullability.
- Mark every `_`-prefixed instance field and method `protected` across all
components (409 members). `protected`, not `private`, so subclasses keep
access. Public API methods and statics stay public. Two carousel data-api
hooks stay public because the module-level handlers call them.
- Retype `getOrCreateInstance`'s config to `NonNullable<ConstructorParameters<T>[1]>`
so it still enforces each component's config now that `_config` is protected
(indexing a protected member on a type parameter is illegal).
- Fix three assert-then-test contradictions found by the review: the `menu`
submenu-keydown guard, and the `chips`/`otp-input` constructors that asserted
`findOne(...)!` then tested the result for null. Each now handles the null in
a local, so the guard is honest and no `!` remains.
The type tests (`api.ts`, `consumer.ts`) now assert consumers cannot reach the
protected internals.
Copy file name to clipboardExpand all lines: AGENTS.md
+3-2Lines changed: 3 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -52,9 +52,10 @@ Act as a teacher for JavaScript, TypeScript, React, and all JavaScript-family to
52
52
53
53
- Source is TypeScript (`js/src/**/*.ts`, entry `js/src/index.ts`); ESM-only, no semicolons, 2-space indent
54
54
- Imports use `.js` extensions (standard TS ESM style); the build resolves them to `.ts` via `build/rollup-plugin-ts-resolve.cjs`
55
-
- Strict tsconfig with `verbatimModuleSyntax` + `erasableSyntaxOnly`; Babel (`@babel/preset-typescript`) strips types, `tsc` only type-checks and emits `.d.ts` (`npm run js-typecheck`, `npm run js-compile-types`)
56
-
- Components extend `BaseComponent` (which extends `Config`); per-component config `type XxxConfig` typed off `Default`, refined on the class via `declare _config: XxxConfig`
55
+
- Strict tsconfig with `verbatimModuleSyntax` + `erasableSyntaxOnly`; Babel (`@babel/preset-typescript`) strips types, `tsc` only type-checks and emits `.d.ts` (`npm run js-typecheck`, `npm run js-emit-types`)
56
+
- Components extend `BaseComponent` (which extends `Config`); per-component config `type XxxConfig` typed off `Default`, refined on the class via `protected declare _config: XxxConfig`
57
57
- Instance fields use `declare` (no runtime emit); constructor `element` param stays optional to keep `typeof Component` assignable to `typeof BaseComponent`
58
+
- Every `_`-prefixed instance member is `protected` (never `private`, so subclasses keep access); public API methods and statics stay public. This keeps the internals out of the published `.d.ts` surface
0 commit comments