{"record":{"id":"2159b54d37b99ce6","repo":"amruthpillai/reactive-resume","slug":"a-compound-selector-can-contain-only-one-type-sele","errorCode":null,"errorMessage":"A compound selector can contain only one type selector.","messagePattern":"A compound selector can contain only one type selector\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/resume/src/stylesheet/selector.ts","lineNumber":122,"sourceCode":"\treturn type ? new Set(SEMANTIC_REGISTRY_V1[type].roles) : knownRoles;\n}\n\nfunction roleValueIsKnown(matcher: AttributeMatcher | null, value: string | null, roles: ReadonlySet<string>): boolean {\n\tif (!matcher || value === null) return roles.size > 0;\n\tif (matcher === \"~=\") return roles.has(value);\n\tif (matcher === \"=\") {\n\t\tconst tokens = value.split(/\\s+/).filter(Boolean);\n\t\treturn tokens.length > 0 && tokens.every((token) => roles.has(token));\n\t}\n\n\treturn [...roles].some((role) => matchesAttribute(role, matcher, value));\n}\n\nfunction validateCompound(selectors: readonly CompiledSimpleSelector[]): void {\n\tconst types = selectors.filter(\n\t\t(selector): selector is Extract<CompiledSimpleSelector, { type: \"type\" }> => selector.type === \"type\",\n\t);\n\tif (types.length > 1) throw new Error(\"A compound selector can contain only one type selector.\");\n\n\tconst type = types[0]?.name ?? null;\n\tfor (const selector of selectors) {\n\t\tif (selector.type !== \"attribute\") continue;\n\n\t\tif (selector.name === \"id\") continue;\n\t\tif (selector.name === \"role\") {\n\t\t\tif (!roleValueIsKnown(selector.matcher, selector.value, allowedRoles(type))) {\n\t\t\t\tthrow new Error(\"Selector uses an unknown role.\");\n\t\t\t}\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (type && !(SEMANTIC_REGISTRY_V1[type].attributes as readonly string[]).includes(selector.name)) {\n\t\t\tthrow new Error(`Attribute ${selector.name} is not available on ${type}.`);\n\t\t}\n\t}\n}","sourceCodeStart":104,"sourceCodeEnd":140,"githubUrl":"https://github.com/amruthpillai/reactive-resume/blob/3a5b12e2a40374a9571988701fcb75c5a1831c42/packages/resume/src/stylesheet/selector.ts#L104-L140","documentation":"validateCompound inspects the list of compiled simple selectors that form one compound selector and counts how many have type 'type'. A compound selector (no combinator) may contain at most one type selector (an element/tag). If two or more are present the compiler throws, because such a selector is meaningless in CSS (e.g. two tags adjoined).","triggerScenarios":"A selector string the compiler decomposed into multiple type selectors inside one compound — typically a malformed selector without a combinator between two tag names, or a custom syntax the compiler mis-tokenized into adjacent types.","commonSituations":"User/AI-authored selector like 'divspan' or 'div p' parsed incorrectly; a templating layer concatenating two type tokens without a combinator; misuse of the semantic type registry producing two type matches.","solutions":["Insert the intended combinator: descendant (' '), child ('>'), etc., so the two type selectors are not in the same compound.","If you meant an attribute/role restriction on a single type, keep only one type selector and express the rest as attributes (e.g. div[role='x']).","Re-run the selector through the compiler in isolation to see the compiled simple-selector list and confirm where the second type came from."],"exampleFix":"/* before: two types in one compound (invalid) */\ndivspan { ... }\n/* after */\ndiv span { ... }   /* descendant */\n/* or */\ndiv[role='card'] { ... }","handlingStrategy":"validation","validationCode":"function countTypeSelectors(selector: string): number {\n  // rough heuristic: count bare tag tokens not separated by a combinator\n  const types = selector.match(/(^|\\s)[a-zA-Z][\\w-]*(?=$|\\s|\\.|#|\\[|:)/g) ?? [];\n  return types.length;\n}","typeGuard":"function isSingleCompoundType(selectors: CompiledSimpleSelector[]): boolean {\n  return selectors.filter(s => s.type === 'type').length <= 1;\n}","tryCatchPattern":"try { compileSelector(selector); }\ncatch (e) { if (/only one type selector/.test(String((e as Error).message))) { reportInvalidSelector(selector); return; } throw e; }","preventionTips":["Insert a combinator between two tag selectors.","Express additional restrictions as attributes, not extra types.","Compile the selector in isolation to inspect the simple-selector list."],"tags":["stylesheet","css","csstree","selector","compound","validation"],"backgroundTag":null,"analyzedSha":"3a5b12e2a40374a9571988701fcb75c5a1831c42","analyzedAt":"2026-08-12T22:31:22.666Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}