theme build does not generate the CustomTextTypes augmentation it documents
- Dominant language
- TypeScript
- Stars
- 13.1k
- Forks
- 1.1k
- Avg merge
- 1d 14h
- Merged PRs (30d)
- 669
Description
`theme/types.ts` promises this:
```ts
/**
* declare module '@astryxdesign/core/theme' {
* interface CustomTextTypes { hero: true; caption: true }
* }
*
* `astryx theme build` generates these augmentations automatically when it
* detects new `type:*` values in a theme's component overrides.
*/
```
It does not. A theme with
```ts
components: {text: {'type:score': {fontVariantNumeric: 'tabular-nums'}}}
```
gets the CSS but no `.variants.d.ts` entry, so `` does not typecheck. `variant:*` values do generate augmentations in the same build (verified side by side: a theme with a custom Button variant and a custom Text type emitted only the Button one).
Why: `generateVariantDeclarationsAsync()` derives the target interface name from the component and prop — `text` + `type` → `TextTypeMap` in `@astryxdesign/core/Text` — and skips when that interface does not exist. For text types the extension point is a differently-named interface in a different module: `CustomTextTypes` in `@astryxdesign/core/theme`.
The manual recipe in the docstring does work — I checked it against the real `dist` types:
```ts
import type {TextType} from '@astryxdesign/core/theme';
declare module '@astryxdesign/core/theme' {
interface CustomTextTypes { hero: true }
}
const a: TextType = 'hero'; // errors without the augmentation, typechecks with it
```
So the fix is a mapping in the generator from `text` + `type` to that module/interface pair, rather than a new extension point.
Worth checking whether any other prop is in the same position (a documented custom-value axis whose extension point does not follow the `Map` convention).
Contributor guide
Assessment
This issue has not been assessed yet.