-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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
Publish block editor build types #49969
base: trunk
Are you sure you want to change the base?
Conversation
Currently down to just a couple errors: Incorrect published types for /Users/noahallen/source/gutenberg/packages/block-editor/build-types/index.d.ts:
packages/block-editor/build-types/components/block-list/use-block-props/index.d.ts(21,14): error TS2552: Cannot find name 'getBlockProps'. Did you mean 'useBlockProps'?
packages/block-editor/build-types/components/inner-blocks/index.d.ts(29,14): error TS2552: Cannot find name 'getInnerBlocksProps'. Did you mean 'useInnerBlocksProps'? These are a little tricky. Any suggestions? This the source code for one of those errors, but they are both the same: gutenberg/packages/block-editor/src/components/inner-blocks/index.js Lines 12 to 16 in fff6d81
|
@@ -12,6 +12,10 @@ import { chevronRightSmall, Icon } from '@wordpress/icons'; | |||
import BlockTitle from '../block-title'; | |||
import { store as blockEditorStore } from '../../store'; | |||
|
|||
/** | |||
* @typedef {import('@wordpress/element').WPElement} WPElement |
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.
Basically all the issues in block-editor were just that we weren't importing types like this.
@@ -13,8 +13,6 @@ import { store as blockEditorStore } from '../../store'; | |||
import { BlockRefsProvider } from './block-refs-provider'; | |||
import { unlock } from '../../lock-unlock'; | |||
|
|||
/** @typedef {import('@wordpress/data').WPDataRegistry} WPDataRegistry */ |
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.
this appears to be unused but was causing an error
@@ -30,7 +30,8 @@ import type { ViewProps } from './types'; | |||
// @ts-expect-error | |||
export const View: WordPressComponent< | |||
'div', | |||
ViewProps & RefAttributes< any > | |||
ViewProps & RefAttributes< any >, | |||
true |
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.
temporary fix so that I could see other type errors. (This will be solved by #49960)
Cc @johnhooks |
@noahtallen I have two PRs that could be helpful in typing the block editor.
Also, I'm very willing to help type the block editor, just point me in the right direction. |
Very nice! My goal with this is to basically let us publish types without requiring checkJs. I added a script in #49736 which helps us avoid publishing any errors. After discussion with @dmsnell, @tyxla, and @adamziel, my thought process is that we still get a ton of value by publishing what we can, even if it’s inferred from JSDoc. It’s hard to maintain DT, and if we publish here, we can remove that from the equation. Then, we can continue improving types (which is the hardest part!) until checkJs could be enabled! So the published types gradually get better and better — but we still get a lot out of the box (like full types for the store, which is harder to do in DT!) I think the only thing blocking this PR now is the error I mentioned above. but I’ll also take a look at those PRs! |
Deviations from DT are probably the biggest unknown. In some packages, I don’t think this is a big enough issue to block things. Maybe that’s different since block editor is so big 🤔 |
I haven't spent a bunch of time on this one, but it might mean that we might need to publish types for the |
I'll try merging this into a fork of #48604 and see if it helps. Edit: @tyxla you were right the issue was |
Thanks for verifying @johnhooks! Seems like we should land those PRs in a sequence. Besides the |
@tyxla I'm currently reviewing the entire PR, I hope to have it cleaned up by the end of the week. I was also attempting to type the internals of the package, though this will be an on going process. Should I leave those changes or remove them and save it for later, concentrating on just providing exported types? |
Sounds great, thanks @johnhooks!
My suggestion would be to leave the internals for another time and focus on the exported types. That can also be a good way to split the work into more bearable and easy-to-grok and easy-to-land pieces. |
What?
Publishes block editor build types. (This package is a lot bigger, and I think the types published are going to be pretty helpful.)
Why?
See #49647
How?
Testing Instructions