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 #1921

Closed
wants to merge 2 commits into from
Closed

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 used Container['nodes'] instead of ChildNodes[], I can change that if you prefer it that way. I have also added a unit test to enforce this behavior (AtRule#nodes being undefined when the body is missing).

Closes #1920.

* layer.nodes //=> undefined
* ```
*/
node: Container['nodes'] | undefined
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should it be nodes: instead of node:?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, sorry. I was wondering why that was working all of a sudden. Because with this change TS is not happy:

Property 'nodes' in type 'AtRule_' is not assignable to the same property in base type 'Container_'.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will open a new PR, I already have a branch ready :D

@tim-we tim-we closed this Feb 3, 2024
@tim-we tim-we mentioned this pull request Feb 3, 2024
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