From c78c95ca5e66e7addd434248e4d0c248f6b0c8cd Mon Sep 17 00:00:00 2001 From: Claude Date: Fri, 10 Jul 2026 21:53:26 +0000 Subject: [PATCH 1/2] Reduce node-types.ts boilerplate to shrink published .d.ts Factor the ~44 near-identical node-type declarations (CSSNode & { type, type_name, clone(): ToPlain }) into two small internal generics, Leaf<> and WithClone<>, instead of hand-rolling each one. Purely a type-level change (zero runtime/JS output difference, zero public API change) that shrinks the largest file in the published tarball (node-types.d.ts: 25.17kB -> 22.18kB), cutting overall unpacked install size by ~1.5%. --- src/node-types.ts | 683 ++++++++++++++++++++++------------------------ 1 file changed, 329 insertions(+), 354 deletions(-) diff --git a/src/node-types.ts b/src/node-types.ts index 4f4814b..7bb5d92 100644 --- a/src/node-types.ts +++ b/src/node-types.ts @@ -87,6 +87,29 @@ export type CSSNode = { | { readonly has_next: true; readonly next_sibling: CSSNode } ) +// --------------------------------------------------------------------------- +// Shared builders — every node type below is assembled from these instead of +// hand-rolling `CSSNode & { type, type_name, clone(): ToPlain }` each +// time. They compile away entirely (types only); their only cost is here, +// once, rather than repeated on every one of the ~40 node types below. +// --------------------------------------------------------------------------- + +/** + * A boolean discriminant paired with the value it gates, e.g. `has_prelude` / + * `prelude`: `T` when the flag is true, `null` when it's false. + */ +type Toggle = + | ({ readonly [K in HasKey]: true } & { readonly [K in ValueKey]: T }) + | ({ readonly [K in HasKey]: false } & { readonly [K in ValueKey]: null }) + +/** Adds a `clone()` whose return type is `ToPlain` for this exact T. */ +type WithClone = T & { clone(options?: CloneOptions): ToPlain } + +/** A node with no children: CSSNode + a literal type tag + any extra fields. */ +type Leaf = WithClone< + CSSNode & Extra & { readonly type: Type; readonly type_name: Name } +> + /** * Mixin for node types that have child nodes. * @@ -141,58 +164,46 @@ export type ToPlain = PlainCSSNode & { type: T['type'] } & { // Structural nodes // --------------------------------------------------------------------------- -export type StyleSheet = CSSNode & - WithChildren & { - readonly type: typeof STYLESHEET - readonly type_name: 'StyleSheet' - clone(options?: CloneOptions): ToPlain +export type StyleSheet = WithClone< + CSSNode & WithChildren & { readonly type: typeof STYLESHEET; readonly type_name: 'StyleSheet' } +> + +export type Rule = WithClone< + CSSNode & + /** SELECTOR_LIST (parse_selectors=true) or RAW (parse_selectors=false) */ + Toggle<'has_prelude', 'prelude', SelectorList | Raw> & + Toggle<'has_block', 'block', Block> & { + readonly type: typeof STYLE_RULE + readonly type_name: 'Rule' + readonly has_declarations: boolean + } +> + +export type Atrule = WithClone< + CSSNode & + /** AT_RULE_PRELUDE (parse_atrule_preludes=true) or RAW (parse_atrule_preludes=false) */ + Toggle<'has_prelude', 'prelude', AtrulePrelude | Raw> & + Toggle<'has_block', 'block', Block> & { + readonly type: typeof AT_RULE + readonly type_name: 'Atrule' + /** At-rule keyword, e.g. "media", "keyframes" */ + readonly name: string + readonly has_declarations: boolean + } +> + +export type Declaration = Leaf< + typeof DECLARATION, + 'Declaration', + { + /** Property name, e.g. "color" */ + readonly property: string + /** VALUE node (parse_values=true), RAW node (parse_values=false), or null */ + readonly value: Value | Raw | null + readonly is_important: boolean + readonly is_browserhack: boolean } - -export type Rule = CSSNode & { - readonly type: typeof STYLE_RULE - readonly type_name: 'Rule' - readonly has_declarations: boolean - clone(options?: CloneOptions): ToPlain -} & - /** SELECTOR_LIST (parse_selectors=true) or RAW (parse_selectors=false) */ - ( - | { readonly has_prelude: true; readonly prelude: SelectorList | Raw } - | { readonly has_prelude: false; readonly prelude: null } - ) & - ( - | { readonly has_block: true; readonly block: Block } - | { readonly has_block: false; readonly block: null } - ) - -export type Atrule = CSSNode & { - readonly type: typeof AT_RULE - readonly type_name: 'Atrule' - /** At-rule keyword, e.g. "media", "keyframes" */ - readonly name: string - readonly has_declarations: boolean - clone(options?: CloneOptions): ToPlain -} & - /** AT_RULE_PRELUDE (parse_atrule_preludes=true) or RAW (parse_atrule_preludes=false) */ - ( - | { readonly has_prelude: true; readonly prelude: AtrulePrelude | Raw } - | { readonly has_prelude: false; readonly prelude: null } - ) & - ( - | { readonly has_block: true; readonly block: Block } - | { readonly has_block: false; readonly block: null } - ) - -export type Declaration = CSSNode & { - readonly type: typeof DECLARATION - readonly type_name: 'Declaration' - /** Property name, e.g. "color" */ - readonly property: string - /** VALUE node (parse_values=true), RAW node (parse_values=false), or null */ - readonly value: Value | Raw | null - readonly is_important: boolean - readonly is_browserhack: boolean - clone(options?: CloneOptions): ToPlain -} +> export type SelectorNode = | TypeSelector @@ -207,19 +218,13 @@ export type SelectorNode = | PseudoClassSelector | PseudoElementSelector -export type Selector = CSSNode & - WithChildren & { - readonly type: typeof SELECTOR - readonly type_name: 'Selector' - clone(options?: CloneOptions): ToPlain - } +export type Selector = WithClone< + CSSNode & WithChildren & { readonly type: typeof SELECTOR; readonly type_name: 'Selector' } +> -export type SelectorList = CSSNode & - WithChildren & { - readonly type: typeof SELECTOR_LIST - readonly type_name: 'SelectorList' - clone(options?: CloneOptions): ToPlain - } +export type SelectorList = WithClone< + CSSNode & WithChildren & { readonly type: typeof SELECTOR_LIST; readonly type_name: 'SelectorList' } +> /** * A node that appears as a direct child of a Block. @@ -230,34 +235,24 @@ export type SelectorList = CSSNode & * there is no recursive type graph to trigger TS2589. */ export type BlockChild = (Raw | Declaration | Atrule | Rule) & - ( - | { readonly has_next: false; readonly next_sibling: null } - | { readonly has_next: true; readonly next_sibling: Raw | Declaration | Atrule | Rule } - ) - -export type Block = CSSNode & - WithChildren & { - readonly type: typeof BLOCK - readonly type_name: 'Block' - readonly is_empty: boolean - /** Block children with next_sibling narrowed to the Block child union. */ - readonly first_child: BlockChild - readonly children: BlockChild[] - [Symbol.iterator](): Iterator - clone(options?: CloneOptions): ToPlain - } + Toggle<'has_next', 'next_sibling', Raw | Declaration | Atrule | Rule> -export type Comment = CSSNode & { - readonly type: typeof COMMENT - readonly type_name: 'Comment' - clone(options?: CloneOptions): ToPlain -} +export type Block = WithClone< + CSSNode & + WithChildren & { + readonly type: typeof BLOCK + readonly type_name: 'Block' + readonly is_empty: boolean + /** Block children with next_sibling narrowed to the Block child union. */ + readonly first_child: BlockChild + readonly children: BlockChild[] + [Symbol.iterator](): Iterator + } +> -export type Raw = CSSNode & { - readonly type: typeof RAW - readonly type_name: 'Raw' - clone(options?: CloneOptions): ToPlain -} +export type Comment = Leaf + +export type Raw = Leaf // --------------------------------------------------------------------------- // Value nodes @@ -275,280 +270,268 @@ type ValueLike = | Dimension | Number -export type Identifier = CSSNode & { - readonly type: typeof IDENTIFIER - readonly type_name: 'Identifier' - readonly name: string - clone(options?: CloneOptions): ToPlain -} +export type Identifier = Leaf -export type Number = CSSNode & { - readonly type: typeof NUMBER - readonly type_name: 'Number' - readonly value: number - clone(options?: CloneOptions): ToPlain -} +export type Number = Leaf -export type Dimension = CSSNode & { - readonly type: typeof DIMENSION - readonly type_name: 'Dimension' - readonly value: number - /** Unit string, e.g. "px", "%" */ - readonly unit: string - clone(options?: CloneOptions): ToPlain -} - -export type String = CSSNode & { - readonly type: typeof STRING - readonly type_name: 'String' - clone(options?: CloneOptions): ToPlain -} - -export type Hash = CSSNode & { - readonly type: typeof HASH - readonly type_name: 'Hash' - clone(options?: CloneOptions): ToPlain -} - -export type Function = CSSNode & - WithChildren & { - readonly type: typeof FUNCTION - readonly type_name: 'Function' - /** Function name, e.g. "rgb", "calc" */ - readonly name: string - /** Function arguments as raw text, e.g. "255, 0, 0" for rgb(255, 0, 0) */ - readonly value: string | null - clone(options?: CloneOptions): ToPlain +export type Dimension = Leaf< + typeof DIMENSION, + 'Dimension', + { + readonly value: number + /** Unit string, e.g. "px", "%" */ + readonly unit: string } +> + +export type String = Leaf + +export type Hash = Leaf + +export type Function = WithClone< + CSSNode & + WithChildren & { + readonly type: typeof FUNCTION + readonly type_name: 'Function' + /** Function name, e.g. "rgb", "calc" */ + readonly name: string + /** Function arguments as raw text, e.g. "255, 0, 0" for rgb(255, 0, 0) */ + readonly value: string | null + } +> + +export type Operator = Leaf< + typeof OPERATOR, + 'Operator', + { + /** The operator character(s), e.g. ",", "+", "-" */ + readonly value: string + } +> -export type Operator = CSSNode & { - readonly type: typeof OPERATOR - readonly type_name: 'Operator' - /** The operator character(s), e.g. ",", "+", "-" */ - readonly value: string - clone(options?: CloneOptions): ToPlain -} +export type Parenthesis = WithClone< + CSSNode & WithChildren & { readonly type: typeof PARENTHESIS; readonly type_name: 'Parentheses' } +> -export type Parenthesis = CSSNode & - WithChildren & { - readonly type: typeof PARENTHESIS - readonly type_name: 'Parentheses' - clone(options?: CloneOptions): ToPlain +export type Url = Leaf< + typeof URL, + 'Url', + { + /** URL content, e.g. '"image.png"' (with quotes) or 'mycursor.cur' (unquoted) */ + readonly value: string | null } +> -export type Url = CSSNode & { - readonly type: typeof URL - readonly type_name: 'Url' - /** URL content, e.g. '"image.png"' (with quotes) or 'mycursor.cur' (unquoted) */ - readonly value: string | null - clone(options?: CloneOptions): ToPlain -} - -export type UnicodeRange = CSSNode & { - readonly type: typeof UNICODE_RANGE - readonly type_name: 'UnicodeRange' - clone(options?: CloneOptions): ToPlain -} +export type UnicodeRange = Leaf -export type Value = CSSNode & - WithChildren & { - readonly type: typeof VALUE - readonly type_name: 'Value' - clone(options?: CloneOptions): ToPlain - } +export type Value = WithClone< + CSSNode & WithChildren & { readonly type: typeof VALUE; readonly type_name: 'Value' } +> // --------------------------------------------------------------------------- // Selector nodes // --------------------------------------------------------------------------- -export type TypeSelector = CSSNode & { - readonly type: typeof TYPE_SELECTOR - readonly type_name: 'TypeSelector' - /** Local element name, e.g. "div" in both "div" and "ns|div" */ - readonly name: string - /** Namespace prefix: null if no qualifier, '' for |div, 'ns' for ns|div, '*' for *|div */ - readonly namespace: string | null - clone(options?: CloneOptions): ToPlain -} - -export type ClassSelector = CSSNode & { - readonly type: typeof CLASS_SELECTOR - readonly type_name: 'ClassSelector' - /** Class name without dot, e.g. "foo" from ".foo" */ - readonly name: string - clone(options?: CloneOptions): ToPlain -} - -export type IdSelector = CSSNode & { - readonly type: typeof ID_SELECTOR - readonly type_name: 'IdSelector' - /** Id without hash, e.g. "bar" from "#bar" */ - readonly name: string - clone(options?: CloneOptions): ToPlain -} - -export type AttributeSelector = CSSNode & { - readonly type: typeof ATTRIBUTE_SELECTOR - readonly type_name: 'AttributeSelector' - /** Attribute name, e.g. "href" from "[href]" */ - readonly name: string - /** Operator string, e.g. "=", "~=", "|="; null if no operator ([attr] form) */ - readonly attr_operator: string | null - /** Flag character, e.g. "i", "s"; null if no flag */ - readonly attr_flags: string | null - /** Attribute value, e.g. "external" from [rel="external"] */ - readonly value: string | null - clone(options?: CloneOptions): ToPlain -} - -export type PseudoClassSelector = CSSNode & - WithChildren & { - readonly type: typeof PSEUDO_CLASS_SELECTOR - readonly type_name: 'PseudoClassSelector' - /** Pseudo-class name without colon, e.g. "hover" */ +export type TypeSelector = Leaf< + typeof TYPE_SELECTOR, + 'TypeSelector', + { + /** Local element name, e.g. "div" in both "div" and "ns|div" */ readonly name: string - clone(options?: CloneOptions): ToPlain + /** Namespace prefix: null if no qualifier, '' for |div, 'ns' for ns|div, '*' for *|div */ + readonly namespace: string | null } +> -export type PseudoElementSelector = CSSNode & - WithChildren & { - readonly type: typeof PSEUDO_ELEMENT_SELECTOR - readonly type_name: 'PseudoElementSelector' - /** Pseudo-element name without colons, e.g. "before" */ +export type ClassSelector = Leaf< + typeof CLASS_SELECTOR, + 'ClassSelector', + { + /** Class name without dot, e.g. "foo" from ".foo" */ readonly name: string - clone(options?: CloneOptions): ToPlain } +> -export type Combinator = CSSNode & { - readonly type: typeof COMBINATOR - readonly type_name: 'Combinator' - /** Combinator character(s), e.g. " ", ">", "~", "+", "||", "/deep/" */ - readonly name: string - clone(options?: CloneOptions): ToPlain -} - -export type UniversalSelector = CSSNode & { - readonly type: typeof UNIVERSAL_SELECTOR - readonly type_name: 'UniversalSelector' - /** Always null — universal selector has no element name */ - readonly name: null - /** Namespace prefix: null if no qualifier, '' for |*, 'ns' for ns|*, '*' for *|* */ - readonly namespace: string | null - clone(options?: CloneOptions): ToPlain -} - -export type NestingSelector = CSSNode & { - readonly type: typeof NESTING_SELECTOR - readonly type_name: 'NestingSelector' - clone(options?: CloneOptions): ToPlain -} - -export type NthSelector = CSSNode & { - readonly type: typeof NTH_SELECTOR - readonly type_name: 'Nth' - /** The `An` part of the An+B formula, including keywords `odd`/`even`. Null when only a B value is present (e.g. `:nth-child(3)`). */ - readonly nth_a: string | null - /** The `+B` part of the An+B formula. Null when only an A value is present (e.g. `:nth-child(2n)` or `:nth-child(odd)`). */ - readonly nth_b: string | null - clone(options?: CloneOptions): ToPlain -} - -export type NthOfSelector = CSSNode & { - readonly type: typeof NTH_OF_SELECTOR - readonly type_name: 'NthOf' - /** The An+B formula node */ - readonly nth: NthSelector | null - /** The selector list from :nth-child(An+B of ) */ - readonly selector: SelectorList | null - clone(options?: CloneOptions): ToPlain -} +export type IdSelector = Leaf< + typeof ID_SELECTOR, + 'IdSelector', + { + /** Id without hash, e.g. "bar" from "#bar" */ + readonly name: string + } +> -export type LangSelector = CSSNode & { - readonly type: typeof LANG_SELECTOR - readonly type_name: 'Lang' - /** `"nl"`, `en-US` */ - readonly name: string | null - clone(options?: CloneOptions): ToPlain -} +export type AttributeSelector = Leaf< + typeof ATTRIBUTE_SELECTOR, + 'AttributeSelector', + { + /** Attribute name, e.g. "href" from "[href]" */ + readonly name: string + /** Operator string, e.g. "=", "~=", "|="; null if no operator ([attr] form) */ + readonly attr_operator: string | null + /** Flag character, e.g. "i", "s"; null if no flag */ + readonly attr_flags: string | null + /** Attribute value, e.g. "external" from [rel="external"] */ + readonly value: string | null + } +> + +export type PseudoClassSelector = WithClone< + CSSNode & + WithChildren & { + readonly type: typeof PSEUDO_CLASS_SELECTOR + readonly type_name: 'PseudoClassSelector' + /** Pseudo-class name without colon, e.g. "hover" */ + readonly name: string + } +> + +export type PseudoElementSelector = WithClone< + CSSNode & + WithChildren & { + readonly type: typeof PSEUDO_ELEMENT_SELECTOR + readonly type_name: 'PseudoElementSelector' + /** Pseudo-element name without colons, e.g. "before" */ + readonly name: string + } +> + +export type Combinator = Leaf< + typeof COMBINATOR, + 'Combinator', + { + /** Combinator character(s), e.g. " ", ">", "~", "+", "||", "/deep/" */ + readonly name: string + } +> + +export type UniversalSelector = Leaf< + typeof UNIVERSAL_SELECTOR, + 'UniversalSelector', + { + /** Always null — universal selector has no element name */ + readonly name: null + /** Namespace prefix: null if no qualifier, '' for |*, 'ns' for ns|*, '*' for *|* */ + readonly namespace: string | null + } +> + +export type NestingSelector = Leaf + +export type NthSelector = Leaf< + typeof NTH_SELECTOR, + 'Nth', + { + /** The `An` part of the An+B formula, including keywords `odd`/`even`. Null when only a B value is present (e.g. `:nth-child(3)`). */ + readonly nth_a: string | null + /** The `+B` part of the An+B formula. Null when only an A value is present (e.g. `:nth-child(2n)` or `:nth-child(odd)`). */ + readonly nth_b: string | null + } +> + +export type NthOfSelector = Leaf< + typeof NTH_OF_SELECTOR, + 'NthOf', + { + /** The An+B formula node */ + readonly nth: NthSelector | null + /** The selector list from :nth-child(An+B of ) */ + readonly selector: SelectorList | null + } +> + +export type LangSelector = Leaf< + typeof LANG_SELECTOR, + 'Lang', + { + /** `"nl"`, `en-US` */ + readonly name: string | null + } +> // --------------------------------------------------------------------------- // At-rule prelude nodes // --------------------------------------------------------------------------- -export type AtrulePrelude = CSSNode & - WithChildren< - | Raw - | MediaQuery - | MediaType - | ContainerQuery - | SupportsQuery - | LayerName - | PreludeOperator - | PreludeSelectorList - | Parenthesis - | Url - > & { - readonly type: typeof AT_RULE_PRELUDE - readonly type_name: 'AtrulePrelude' - clone(options?: CloneOptions): ToPlain +export type AtrulePrelude = WithClone< + CSSNode & + WithChildren< + | Raw + | MediaQuery + | MediaType + | ContainerQuery + | SupportsQuery + | LayerName + | PreludeOperator + | PreludeSelectorList + | Parenthesis + | Url + > & { readonly type: typeof AT_RULE_PRELUDE; readonly type_name: 'AtrulePrelude' } +> + +export type MediaQuery = WithClone< + CSSNode & + WithChildren & { + readonly type: typeof MEDIA_QUERY + readonly type_name: 'MediaQuery' + } +> + +export type MediaFeature = Leaf< + typeof MEDIA_FEATURE, + 'Feature', + { + /** Feature name, e.g. "min-width" */ + readonly property: string + /** Feature value node, or null for boolean features like (hover) */ + readonly value: CSSNode | null } +> -export type MediaQuery = CSSNode & - WithChildren & { - readonly type: typeof MEDIA_QUERY - readonly type_name: 'MediaQuery' - clone(options?: CloneOptions): ToPlain - } - -export type MediaFeature = CSSNode & { - readonly type: typeof MEDIA_FEATURE - readonly type_name: 'Feature' - /** Feature name, e.g. "min-width" */ - readonly property: string - /** Feature value node, or null for boolean features like (hover) */ - readonly value: CSSNode | null - clone(options?: CloneOptions): ToPlain -} - -export type MediaType = CSSNode & { - readonly type: typeof MEDIA_TYPE - readonly type_name: 'MediaType' - /** Media type text, e.g. "screen", "print" */ - readonly value: string - clone(options?: CloneOptions): ToPlain -} - -export type ContainerQuery = CSSNode & - WithChildren & { - readonly type: typeof CONTAINER_QUERY - readonly type_name: 'ContainerQuery' - clone(options?: CloneOptions): ToPlain - } - -export type SupportsQuery = CSSNode & - WithChildren & { - readonly type: typeof SUPPORTS_QUERY - readonly type_name: 'SupportsQuery' - /** The supports condition text, e.g. "display: flex" from "supports(display: flex)" */ +export type MediaType = Leaf< + typeof MEDIA_TYPE, + 'MediaType', + { + /** Media type text, e.g. "screen", "print" */ readonly value: string - clone(options?: CloneOptions): ToPlain } - -export type SupportsDeclaration = CSSNode & - WithChildren & { - readonly type: typeof SUPPORTS_DECLARATION - readonly type_name: 'SupportsDeclaration' - clone(options?: CloneOptions): ToPlain +> + +export type ContainerQuery = WithClone< + CSSNode & + WithChildren & { + readonly type: typeof CONTAINER_QUERY + readonly type_name: 'ContainerQuery' + } +> + +export type SupportsQuery = WithClone< + CSSNode & + WithChildren & { + readonly type: typeof SUPPORTS_QUERY + readonly type_name: 'SupportsQuery' + /** The supports condition text, e.g. "display: flex" from "supports(display: flex)" */ + readonly value: string + } +> + +export type SupportsDeclaration = WithClone< + CSSNode & + WithChildren & { + readonly type: typeof SUPPORTS_DECLARATION + readonly type_name: 'SupportsDeclaration' + } +> + +export type LayerName = Leaf< + typeof LAYER_NAME, + 'Layer', + { + readonly name: string + /** Alias for name — the layer name string, e.g. "base" from "layer(base)" */ + readonly value: string } - -export type LayerName = CSSNode & { - readonly type: typeof LAYER_NAME - readonly type_name: 'Layer' - readonly name: string - /** Alias for name — the layer name string, e.g. "base" from "layer(base)" */ - readonly value: string - clone(options?: CloneOptions): ToPlain -} +> /** * A parenthesised selector argument in an at-rule prelude. @@ -566,27 +549,19 @@ export type LayerName = CSSNode & { * `value` is the raw selector text inside the parentheses, trimmed of * whitespace: ".parent" from "(.parent)". */ -export type PreludeSelectorList = CSSNode & { - readonly type: typeof PRELUDE_SELECTORLIST - readonly type_name: 'PreludeSelectorList' - readonly value: string - clone(options?: CloneOptions): ToPlain -} - -export type PreludeOperator = CSSNode & { - readonly type: typeof PRELUDE_OPERATOR - readonly type_name: 'Operator' - clone(options?: CloneOptions): ToPlain -} - -export type FeatureRange = CSSNode & - WithChildren & { - readonly type: typeof FEATURE_RANGE - readonly type_name: 'MediaFeatureRange' - /** The feature name in a range comparison, e.g. "width" from "(width >= 400px)" */ - readonly name: string - clone(options?: CloneOptions): ToPlain - } +export type PreludeSelectorList = Leaf + +export type PreludeOperator = Leaf + +export type FeatureRange = WithClone< + CSSNode & + WithChildren & { + readonly type: typeof FEATURE_RANGE + readonly type_name: 'MediaFeatureRange' + /** The feature name in a range comparison, e.g. "width" from "(width >= 400px)" */ + readonly name: string + } +> // --------------------------------------------------------------------------- // AnyCss — discriminated union of all known subtypes From c062f1a2abfef577ec2fc9a6c9c37c0dad584652 Mon Sep 17 00:00:00 2001 From: Claude Date: Sat, 11 Jul 2026 06:21:52 +0000 Subject: [PATCH 2/2] Fix oxfmt formatting in node-types.ts Co-Authored-By: Claude Sonnet 5 Claude-Session: https://claude.ai/code/session_01FuvCERnifYS6ggHAXMwVkD --- src/node-types.ts | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/node-types.ts b/src/node-types.ts index 7bb5d92..320363d 100644 --- a/src/node-types.ts +++ b/src/node-types.ts @@ -219,11 +219,16 @@ export type SelectorNode = | PseudoElementSelector export type Selector = WithClone< - CSSNode & WithChildren & { readonly type: typeof SELECTOR; readonly type_name: 'Selector' } + CSSNode & + WithChildren & { readonly type: typeof SELECTOR; readonly type_name: 'Selector' } > export type SelectorList = WithClone< - CSSNode & WithChildren & { readonly type: typeof SELECTOR_LIST; readonly type_name: 'SelectorList' } + CSSNode & + WithChildren & { + readonly type: typeof SELECTOR_LIST + readonly type_name: 'SelectorList' + } > /** @@ -549,7 +554,11 @@ export type LayerName = Leaf< * `value` is the raw selector text inside the parentheses, trimmed of * whitespace: ".parent" from "(.parent)". */ -export type PreludeSelectorList = Leaf +export type PreludeSelectorList = Leaf< + typeof PRELUDE_SELECTORLIST, + 'PreludeSelectorList', + { readonly value: string } +> export type PreludeOperator = Leaf