Skip to content

SW12002: Declaration identities unavailable

The compiler cannot tell which refs or animations a value can hold.

This error occurs when the compiler cannot tell which refs, keyframes, or view transitions a value can hold. When a ref is chosen at runtime, the compiler must generate CSS for every ref that it can be. A type annotation that widens the type hides that list.

Reported

const card = style.ref("card");
const current: ReturnType<typeof style.ref> = card;
style({ [current("hover")]: "underline" });

SW12002: cannot determine finite declaration identities: Cannot determine a finite set of declaration identities. Preserve the value's inferred type, use an explicit union, or use a generic parameter.

Source format: Jsx

Fixed

const card = style.ref("card");
const current = card;
style({ [current("hover")]: "underline" });

How to fix

  • Remove the type annotation, and keep the type that TypeScript infers, as in the example.
  • When a value can hold several refs, use an explicit union of their types, such as typeof card | typeof panel, or a generic parameter.
  • Make the source modules of the definitions reachable through imports.

If the integration did not provide type information at all, the error is SW30001 instead.