[Solved] No JSX code suggestions for Wordpress packages

While writing code for a Gutenberg block, I'm having mixed results with code suggestions in the JSX.

Regular HTML tags immediately show prop and parameters suggestions, but any import'd WordPress component doesn't (like ToggleControl or PanelBody from @wordpress/components, or RichText from @wordpress/block-editor, etc.). Pressing Ctrl-Space shows the "No suggestions" popup.

Conversely, non-JSX coding shows IntelliJ is well aware of these imported functions. For example, when starting to type...

useBl

IntelliJ offers suggestions as well as insight into other methods related to useBlockProps (from @wordpress/block-editor), like:

useBlockProps.save() 

I could have sworn JSX prop/param code suggestions for WordPress specific components was something I've taken advantage of in the past or am I wrong about that? Perhaps I've a missed configuration detail somewhere.

Does anyone have any advice on how to restore this functionality? 

Thanks!

 

0

Solved! Mostly.

In order to have IntelliJ (WebStorm, etc.) offer code suggestions for these WordPress modules, the corresponding @types/wordpress__xxxxxxx package also needs to be installed.

For example, after installing @types/wordpress__block-editor, code suggestions in the JSX for <RichText /> started working!

I also tried downloading and configuring the same libraries through Preferences > Languages&Frameworks > JavaScript > Libraries > Download, but was not able to get it to work.

I wonder if VS Code does this transparently since I've not had to perform this step using that IDE. ¯\_(ツ)_/¯ 

0

请先登录再写评论。