projectwallace / projectwallace/css-parser
Incorrect types for MediaFeature
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 4
- Forks
- 0
- PR merge metrics
- No merged PRs in 30d
Description
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.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the MediaFeature definition in dist/node-types-mntWKkN-.d.ts and compare its child-related types with the runtime behavior described for min-width:0\0. The work is done when MediaFeature exposes the specified WithChildren union and its value property is narrowed to Identifier, Number, Dimension, or null.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 1/5
- Estimated time
- Under an hour
- Activity status
- Quiet
- Clarity
- Clearly specified
- Newbie friendliness
- 85/100