Skip to content

Commit b2bc282

Browse files
authored
Undeprecate Global React JSX Namespace
DefinitelyTyped#64464 (landed in semver patch release `@types/[email protected]`) scopes the JSX namespace as `React.JSX` to avoid collisions with multiple libraries working in the JSX namespace. This change also deprecated the existing JSX namespace, so existing usages of `JSX.Element`, etc are flagged in-editor. <img width="686" alt="Screenshot 2023-07-25 at 14 11 59" src="https://github.com/facebook/react-native/assets/4661784/531a4f88-8090-43aa-86d6-4af595d4cb5d"> This has a pretty drastic effect of making every previous non-anonymous function component, with an explicit return type, now fire deprecation warnings. E.g. this patch update now makes the out-of-the-box React native template create deprecation warnings. facebook/react-native#38615 In DefinitelyTyped itself, the hundreds of packages using `JSX.Element` outside of the direct React typings were not updated. TypeScript's [own documentation](https://www.typescriptlang.org/docs/handbook/jsx.html) also still suggests using `JSX.Element`. This is echoed by a platitude of existing documentation, and googling for `React.JSX.Element` will just bring up information about `JSX.Element`. Due to the widespread nature of the breakage here (especially in a patch release), and disconnect with existing code, documentation, and resources, this change removes the `@deprecated` annotation. I think there might still be a possible path to discouraging usage, but there needs to be a lot of legwork to get there in a way which isn't disruptive.
1 parent de66435 commit b2bc282

File tree

1 file changed

+0
-3
lines changed

1 file changed

+0
-3
lines changed

types/react/index.d.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3220,9 +3220,6 @@ type ReactManagedAttributes<C, P> = C extends { propTypes: infer T; defaultProps
32203220
: P;
32213221

32223222
declare global {
3223-
/**
3224-
* @deprecated Use `React.JSX` instead of the global `JSX` namespace.
3225-
*/
32263223
namespace JSX {
32273224
// We don't just alias React.ElementType because React.ElementType
32283225
// historically does more than we need it to.

0 commit comments

Comments
 (0)