{"record":{"id":"9780ec2be82fc135","repo":"amruthpillai/reactive-resume","slug":"nth-of-type-does-not-accept-an-of-selector","errorCode":null,"errorMessage":":nth-of-type does not accept an of selector.","messagePattern":":nth-of-type does not accept an of selector\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/resume/src/stylesheet/selector.ts","lineNumber":173,"sourceCode":"\tif (expression.type === \"Identifier\") {\n\t\tconst keyword = astName(expression).toLowerCase();\n\t\tif (keyword === \"odd\") {\n\t\t\ta = 2;\n\t\t\tb = 1;\n\t\t} else if (keyword === \"even\") {\n\t\t\ta = 2;\n\t\t} else {\n\t\t\tthrow new Error(`Unsupported :${name} expression.`);\n\t\t}\n\t} else if (expression.type === \"AnPlusB\") {\n\t\ta = expression.a === null || expression.a === undefined ? 0 : Number(expression.a);\n\t\tb = expression.b === null || expression.b === undefined ? 0 : Number(expression.b);\n\t\tif (!Number.isInteger(a) || !Number.isInteger(b)) throw new Error(`Invalid :${name} expression.`);\n\t} else {\n\t\tthrow new Error(`Unsupported :${name} expression.`);\n\t}\n\n\tif (name === \"nth-of-type\" && nth[0].selector) throw new Error(\":nth-of-type does not accept an of selector.\");\n\tconst of = nth[0].selector ? compileSelectorList(nth[0].selector, { depth: context.depth + 1 }) : undefined;\n\treturn { type: \"pseudo\", name, a, b, ...(of ? { of } : {}) };\n}\n\nfunction compileSimple(node: SelectorAst, context: CompileContext): CompiledSimpleSelector | null {\n\tswitch (node.type) {\n\t\tcase \"TypeSelector\": {\n\t\t\tconst name = astName(node);\n\t\t\tif (name === \"*\") return { type: \"universal\" };\n\t\t\tif (!knownKinds.has(name)) throw new Error(`Unknown semantic element ${name}.`);\n\t\t\treturn { type: \"type\", name: name as SemanticNode[\"kind\"] };\n\t\t}\n\t\tcase \"IdSelector\":\n\t\t\treturn { type: \"id\", value: astName(node) };\n\t\tcase \"AttributeSelector\": {\n\t\t\tconst name = astName(node);\n\t\t\tif (!knownAttributes.has(name)) throw new Error(`Unknown semantic attribute ${name}.`);\n\t\t\tif (node.flags) throw new Error(\"Attribute selector flags are not supported.\");","sourceCodeStart":155,"sourceCodeEnd":191,"githubUrl":"https://github.com/amruthpillai/reactive-resume/blob/3a5b12e2a40374a9571988701fcb75c5a1831c42/packages/resume/src/stylesheet/selector.ts#L155-L191","documentation":"Thrown by compileNth when :nth-of-type is given an 'of <selector>' argument. Unlike :nth-child, :nth-of-type filters by element kind internally and the Selectors Level 4 'of' syntax is disallowed for it in this compiler.","triggerScenarios":"Writing :nth-of-type(2 of section) or any :nth-of-type(... of ...).","commonSituations":"Porting a :nth-child(... of ...) pattern to :nth-of-type; assuming symmetry between the two nth pseudo-classes.","solutions":["Remove the 'of' clause: :nth-of-type(2).","If you need the of-filter semantics, use :nth-child(2 of <selector>) instead.","Filter by type via a surrounding compound rather than the of syntax."],"exampleFix":"// before\nitem:nth-of-type(2 of .featured)\n// after\nitem:nth-child(2 of [role~='nested-role'])","handlingStrategy":"validation","validationCode":"const NTH_OF_TYPE_HAS_NO_OF = !/:nth-of-type\\([^)]*\\bof\\b/.test(selector);\n// reject :nth-of-type(... of ...) before compiling","typeGuard":"const isRejected = (r) => r.selector === null && typeof r.error === 'string';","tryCatchPattern":"const result = compileSelector(selector);\nif (result.selector === null && result.error === ':nth-of-type does not accept an of selector.') {\n  rewriteToNthChildOf(selector);\n}","preventionTips":["Remember :nth-of-type never accepts an 'of' argument; only :nth-child does.","When porting a :nth-child(... of ...) pattern, switch to :nth-child, not :nth-of-type.","Lint for the literal ' of ' inside :nth-of-type parentheses."],"tags":["semantic-css","selector","nth","pseudo-class"],"backgroundTag":null,"analyzedSha":"3a5b12e2a40374a9571988701fcb75c5a1831c42","analyzedAt":"2026-08-12T22:31:22.666Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}