Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve AtRule#nodes type #1922

Merged
merged 9 commits into from Feb 5, 2024
Merged

Improve AtRule#nodes type #1922

merged 9 commits into from Feb 5, 2024

Conversation

tim-we
Copy link
Contributor

@tim-we tim-we commented Feb 3, 2024

Parsing something like

@layer a, b, c;

with postcss will result in an AtRule object without a nodes property. This however is not reflected by the types.

This PR changes the type of AtRule#nodes from ChildNodes[] to ChildNodes[] | undefined and updates the documentation.

I had to change the types of Container#nodes (and undo that change for Root#nodes, Rule#nodes and Document#nodes), I did not find a better approach. Other things I have tried are #1921 and changing this:

declare class AtRule_ extends Container<ChildNode | undefined>

which sadly also does not work because ChildNode | undefined does not extend Node.

Closes #1920.

@tim-we
Copy link
Contributor Author

tim-we commented Feb 3, 2024

I'll have a look at those failing tests 😩

@tim-we
Copy link
Contributor Author

tim-we commented Feb 3, 2024

Fixed tests.

@ai ai merged commit bb0314a into postcss:main Feb 5, 2024
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

AtRule#nodes can be undefined
2 participants