Skip to content

astryx theme build generates custom-variant augmentations against non-existent interface names (XDSButtonVariantMap ≠ ButtonVariantMap) #3371

Closed

Description

@josephfarina

Summary

astryx theme build supports declaring custom component variants in a theme (e.g. components.button['variant:accentOutline']), and the docs say it "generates TypeScript module augmentations for type-safe extensibility." In practice the generated augmentation targets the wrong interface name, so the custom variant is never added to the component's variant union and using it fails to type-check.

Versions: @astryxdesign/[email protected], @astryxdesign/[email protected]

Repro

theme.ts:

import { defineTheme } from "@astryxdesign/core/theme";

export const myTheme = defineTheme({
  name: "mytheme",
  components: {
    button: {
      "variant:accentOutline": {
        backgroundColor: "transparent",
        color: "var(--color-accent)",
        borderColor: "var(--color-accent)",
      },
    },
  },
});
npx astryx theme build theme.ts --out theme.css

Then, in a component:

<Button variant="accentOutline" label="Login" />

Actual

The generated theme.variants.d.ts contains:

declare module '@astryxdesign/core/Button' {
  interface XDSButtonVariantMap {   // <-- wrong interface name
    'accentOutline': true;
  }
}

XDSButtonVariantMap does not exist anywhere in @astryxdesign/core. The Button component declares (in dist/Button/Button.d.ts):

export interface ButtonVariantMap {
  primary: true; secondary: true; ghost: true; destructive: true;
}
export type ButtonVariant = keyof ButtonVariantMap;

So the augmentation just creates a new, unused XDSButtonVariantMap interface and never extends ButtonVariantMap. Result:

error TS2322: Type '"accentOutline"' is not assignable to type 'keyof ButtonVariantMap | undefined'.

The CSS side is emitted correctly (.astryx-button.accentOutline under @layer astryx-theme) and works at runtime — this is purely a codegen type mismatch.

Expected

The generated augmentation should target the component's real extensible interface:

declare module '@astryxdesign/core/Button' {
  interface ButtonVariantMap {
    'accentOutline': true;
  }
}

(This is exactly the form shown in the ButtonVariantMap JSDoc example in Button.d.ts.)

Also affected: Heading (and likely other components)

For the same theme build, Heading augmentations are generated as:

declare module '@astryxdesign/core/Heading' {
  interface XDSHeadingLevelMap { '1': true; ... }
  interface XDSHeadingTypeMap { 'display-1': true; ... }
}

But @astryxdesign/core/Heading declares HeadingLevel/HeadingType as hardcoded literal unions — there are no *Map interfaces and no augmentation extension point at all:

export type HeadingLevel = 1 | 2 | 3 | 4 | 5 | 6;
export type HeadingType = 'display-1' | 'display-2' | 'display-3';

So these augmentations are doubly dead (wrong name + no extension point). This suggests the codegen assumes a uniform XDS-prefixed *Map interface convention that doesn't match the actual public types in core.

Root cause (suspected)

The theme-build codegen's interface-name / extension-point mapping is out of sync with @astryxdesign/core's public types:

  • It prefixes with XDS (XDSButtonVariantMap) where core uses no prefix (ButtonVariantMap).
  • It assumes a *Map extension point for components that don't have one (Heading).

Impact

Custom variants — a documented, first-class extensibility feature — are unusable in a type-safe way. Consumers must hand-write the correct augmentation as a workaround:

// variants.ts (imported for side effect)
export {};
declare module "@astryxdesign/core/Button" {
  interface ButtonVariantMap { accentOutline: true }
}

Activity

  1. self-assigned this
    on Jul 2, 2026
  2. added
    bug
    on Jul 2, 2026
  3. added a commit that references this issue on Jul 3, 2026
    b5d7a7c
  4. added a commit that references this issue on Jul 8, 2026
    9332fcf
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bug

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions