faustjs
faustjs copied to clipboard
TypeScript error: `null` not allowed as `theme` value for WordPressBlocksProvider
Description
If you provide null as the value for theme in your config for WordPressBlocksProvider, you will get an error if your "strict" flag is set to true.
<WordPressBlocksProvider config={{ blocks, theme: null }}>
Type 'null' is not assignable to type 'BlocksTheme | undefined'.ts(2322)
This is because the current type definition does not include null as a valid type:
export type WordPressBlocksProviderConfig = {
blocks: { [key: string]: WordPressBlock };
theme?: BlocksTheme;
};
https://github.com/wpengine/faustjs/blob/canary/packages/blocks/src/components/WordPressBlocksProvider.tsx#L36-L39
To fix, the type should be updated to theme?: BlocksTheme | null.
Steps to reproduce
- Get a TypeScript Faust project (e.g. https://github.com/wpengine/faust-scaffold-ts). Set the
"strict"flag totruein tsconfig. - Install
@faustwp/blocks. - Add
WordPressBlocksProviderto your app and attempt to usenullas thethemevalue for your config.
<WordPressBlocksProvider config={{ blocks: {}, theme: null}}>
The Type 'null' is not assignable to type 'BlocksTheme | undefined' error should appear in your TypeScript checks.
Additional context
No response
@faustwp/core Version
3.0.0
@faustwp/cli Version
3.0.0
FaustWP Plugin Version
N/A
WordPress Version
N/A
Additional environment details
This issue is specific to the @faustwp/blocks package, versions 0.3.1 - 4.0.0.
Please confirm that you have searched existing issues in the repo.
- [X] Yes
Thank you @mdrayer. Would you be able to provide a PR for this?
@theodesp sure, I can give that a go. Would it be best for me to fork the repo and do a PR that way?
@mdrayer Make sure you fork the repo, make your changes, and open a PR against the Canary branch.
We have a contribution guide:
https://github.com/wpengine/faustjs/blob/canary/CONTRIBUTING.md#instructions-for-contributing-code
You also need to complete a CLA form for first PRs
Contributor License Agreement
All external contributors to WP Engine products must have a signed Contributor License Agreement (CLA) in place before the contribution may be accepted into any WP Engine codebase.
- Submit your name and email
- 📝 Sign the CLA emailed to you
- 📥 Receive copy of signed CLA
I believe this has been solved by #1986 Feel free to reopen or comment if that's not the case.