-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Interactivity: Strict type checking #59865
Conversation
b46f01a
to
393c6ba
Compare
packages/interactivity/tsconfig.json
Outdated
"strictNullChecks": false, | ||
"strictPropertyInitialization": false, | ||
|
||
"noImplicitAny": false |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We'll gradually want to remove these so all strictness is enabled.
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.
To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
Size Change: +126 B (+0.01%) Total Size: 1.75 MB
ℹ️ View Unchanged
|
8fc589e
to
67ab2b6
Compare
packages/interactivity/src/vdom.ts
Outdated
* @param root The root element or node to start traversing on. | ||
* @return The resulting vDOM tree. | ||
*/ | ||
export function toVdom( root ) { | ||
export function toVdom( root: Node ): [ string | VNode | null, Node | null ] { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not happy with the changes here…
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
toVdom
is an internal function. So TS here is not critical. Don't let this block your PR 😄
67ab2b6
to
b681df1
Compare
b681df1
to
8110436
Compare
This needs a changelog entry. It's strict null type checked now so the generated types should be better. I think there was an issue around some possible nulls not being reflected in types (around getElement?) that should be fixed now. |
Done in 982606e |
This should fix the types that were a problem in #59757 |
let ignore = false; | ||
let island = false; | ||
|
||
for ( let i = 0; i < attributes.length; i++ ) { | ||
const n = attributes[ i ].name; | ||
const attributeName = attributes[ i ].name; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🚀 Thanks for making this easier to read.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need this PR (we can iterate later if needed) merged asap so it does not conflict with future developments.
Great work @sirreal
What?
Typecheck more of the interactivity package.
Part of #60219
Why?
The package is partially TypeScript and has relaxed strictness that reduces the quality of the produced type declarations.
Types get better!
How?
Migrate more file to TypeScript and fix type errors.
Testing Instructions
CI should be sufficient.