-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Typings change in 3.4.34
breaks our dev flow for almost all our plugins
#1923
Comments
3.4.34
broke almost all our plugins3.4.34
breaks our dev flow for almost all our plugins
Yes, I saw it. But my logic is that previous types was a bug and type is not a core API, but a helper on top of JS code. Some changes should be made, but we can try to make types smarter to avoid all changes.
Maybe we can add some type template like Where else the current types the |
There are a lot of different cases but I'll try and go through the errors and collect some things that might be improved. Method calls like node.append(otherNode.nodes); If |
@romainmenke I made PR for Hope those hacks will not create new problems 😅 I can release it after your review (also suggest any other changes). |
I also checked Stylelint and only one thing surfaced there. There is a helper there : /**
* Check if a statement has an block (empty or otherwise).
*
* @param {import('postcss').Container} statement
* @return {boolean} True if `statement` has a block (empty or otherwise)
*/
export default function hasBlock(statement) {
return statement.nodes !== undefined;
} But it wasn't immediately clear to me how this could be changed into a real type guard. I don't think that if (!hasBlock(atRule)) return;
// I expect TypeScript to know that `nodes` isn't undefined
// when `hasBlock` is a working type guard.
console.log(atRule.nodes.length);
// ^^^^^ errors Maybe this is already possible without extra changes? |
I've tested #1924 and it works really well! see : csstools/postcss-plugins#1271 Thank you for the super fast changes 🙇 I didn't see any changes to test results so I think the runtime changes are good. The added typings really helped :) |
Fixed in 8.4.35. |
Thank you @ai 🎉 |
see : #1922
I agree with the change and I think it is needed to change the types so that
nodes
can be undefined for at rule statements (e.g.@import
,@layer
, ...)But I wonder if a more refined change is possible.
This change is very breaking for us, but not for our users.
Only our own dev flow is affected.
Consider this code :
Here I would assume that
nodes
is known to be notundefined
given that I didnode
->parent
->parent.nodes
.The text was updated successfully, but these errors were encountered: