-
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
@wordpress/element typings reference @types/react-dom, but it doesn't have it as a dependency #23130
Comments
I'm unable to reproduce this issue. @marekdedic can you share more information? TypeScript version, tsconfig, etc. Here's a working codesandbox including this code: import * as element from "@wordpress/element";
const wp: {
element: typeof import("@wordpress/element");
} = { element };
wp.element.render(
wp.element.createElement("div", {}, "Hello, world!"),
document.getElementById("app")
); |
I'm not certain of the best approach or recommended practices here. My thinking has been that the published types expose the public API. Generally, the public API doesn't expose the types of our dependencies. React is a bit of a special case and I can imagine it leaking quite easily, but as I mention above, I haven't been able to observe this in my testing. |
Hi, I do think there's one big difference in your example - the |
I did that for demonstration purposes, but I still don't see an issue using the code you provided. import * as element from "@wordpress/element";
declare const wp: {
components: typeof import("@wordpress/components");
element: typeof import("@wordpress/element");
};
element.render(
element.createElement("div", {}, "Hello, world!"),
document.getElementById("app")
); |
Butting in real quick without doing much diligence to mention that the issue could also be due to a package-lock with stale nested dependencies. Does the issue replicate if you install without a package-lock @marekdedic ? |
Yes it does unfortunately. I haven't had the time to make a minimal example, but in this PR, you can see the issue in action - skaut/skaut-google-drive-gallery#550 Hope this helps |
@sirreal I recreated your CodePen in a gist (because I could not figure out how to run a codepen...). The issue is still there https://gist.github.com/marekdedic/01381b3047e35124d09863e8b408de8a run: $ npm install
$ npm run build |
Thanks, I was able to reproduce with your example @marekdedic. I've opened #25086 to address. |
Upgrade the type packages. Fixes #23130
* Add @types/react and @types/react-dom dependency to element Fixes #23130 * Upgrade the type packages * Add changelog
Describe the bug
Hi. I am developing WordPress plugins using TypeScript and after the recent deprecation of
@types/wordpress__element
, I tried to switch to the type definitions included in@wordpress/element
- I've installed@wordpress/element
as a dev-dependency and included the following type declaration in my project:However, I got the error
Upon closer inspection, I've found out that the type definitions from
@wordpress/element
reference types forreact-dom
, but it has@types/react-dom
only as a dev-dependency. I believe this is a bug and@types/react-dom
should be a dependency for@wordpress/element
so that the type definitions are complete.@wordpress/element
version:2.14.0
Thanks!
The text was updated successfully, but these errors were encountered: