This rule reports a style.ref() label or a ref method argument that is not a
literal. The compiler reads these values at build time, so a value from a variable
cannot name a ref or configure a method.
Reported
declare const label: string;
const card = style.ref(label);invalid-ref-input: style.ref() accepts only an optional literal label
style(card);Fixed
const card = style.ref("card");
style(card);How to fix
- Write the label as a string literal.
- If you need a different ref for each case, declare one ref for each case and
choose between the refs at runtime. Each
style.ref()call already creates a separate name, so the label does not need to differ. - Write method arguments, such as the type of
asContainer(), as literals.
See style.ref().
Rule settings
| Preset | Severity |
|---|---|
recommended | deny |
strict | deny |
stylistic | off |
Configure lint to change the severity or options.