Skip to content

preset-attributify missing type support for print and print: prefix #5118

@KeqingMoe

Description

@KeqingMoe

UnoCSS version

66.6.0

Describe the bug

When using Attributify mode, print:hidden works at runtime but TypeScript reports property missing:

不能将类型“{ "print:hidden": true; }”分配给类型“HTMLAttributes”。
  类型“HTMLAttributes”上不存在属性“print:hidden”。ts(2322)

I'm sure it is a bug, because print:block-0 doesn't trigger the error, while print:hidden and print:block do.

My workaround:

// shims.d.ts
import type { AttributifyAttributes } from '@unocss/preset-attributify';

type VariantPrefixes = 'print';
type UtilityNames = 'hidden' | 'block';

type Variants = {
  [K in VariantPrefixes | `${VariantPrefixes}:${UtilityNames}`]?: boolean | string;
};

declare global {
  namespace astroHTML.JSX {
    interface HTMLAttributes extends AttributifyAttributes, Variants { }
  }
}

Reproduction

<header print:hidden></header>
// shims.d.ts
import type { AttributifyAttributes } from '@unocss/preset-attributify'

declare global {
  namespace astroHTML.JSX {
    interface HTMLAttributes extends AttributifyAttributes { }
  }
}

System Info

OS: macOS Sequoia 15.5 arm64
Astro: 5.17.1

Validations

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions