INNER CODE UNIT · TypeScript
getVariantSuggestions
ben-rogerson/twin.macro · src/suggestions/index.ts:30
function getVariantSuggestions(
variants: string[],
className: string,
context: ClassErrorContext
): string | undefined {
const coreContext = createCoreContext({
tailwindConfig: context?.tailwindConfig,
CustomError: MacroError as typeof Error,
})
const { unmatched } = getStyles(className, coreContext)
if (unmatched.length > 0) return
const unmatchedVariants = variants.filter(v => {
if (v.startsWith('[')) return v
return !context.variants.has(v)
})
if (unmatchedVariants.length === 0) return