MediaFeature type is missing WithChildren
File: dist/node-types-mntWKkN-.d.ts
Problem
MediaFeature can have children beyond the .value node at runtime, but the type does not extend WithChildren. This makes node.has_children and for (const child of node) TypeScript errors even though they work correctly.
A concrete example is the CSS hack min-width:0\0. The parser emits a MediaFeature with two children: a Number node (0) exposed via .value, and a sibling Identifier node (\0) only reachable by iterating children.
Current definition
type MediaFeature = CSSNode & {
readonly type: typeof MEDIA_FEATURE;
readonly type_name: 'Feature';
readonly property: string;
readonly value: CSSNode | null;
clone(options?: CloneOptions): ToPlain<MediaFeature>;
};
Expected definition
type MediaFeature = CSSNode & WithChildren<Identifier | Number | Dimension> & {
readonly type: typeof MEDIA_FEATURE;
readonly type_name: 'Feature';
readonly property: string;
readonly value: Identifier | Number | Dimension | null;
clone(options?: CloneOptions): ToPlain<MediaFeature>;
};
Changes
- Add WithChildren<Identifier | Number | Dimension> — boolean features have no children; plain features have one child matching the value; the 0\0 hack produces two children.
- Narrow value: CSSNode | null → value: Identifier | Number | Dimension | null to match the actual child union.
MediaFeaturetype is missingWithChildrenFile:
dist/node-types-mntWKkN-.d.tsProblem
MediaFeaturecan have children beyond the.valuenode at runtime, but the type does not extendWithChildren. This makesnode.has_childrenandfor (const child of node)TypeScript errors even though they work correctly.A concrete example is the CSS hack
min-width:0\0. The parser emits aMediaFeaturewith two children: aNumbernode (0) exposed via.value, and a siblingIdentifiernode (\0) only reachable by iterating children.Current definition
Expected definition
Changes