-
Notifications
You must be signed in to change notification settings - Fork 29.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[react] Add JSX namespace to React namespace (#64464)
* Move React JSX namespace out of the global * Apply `scoped-jsx@8500bdedae` codemod * Fix import placement breaking DT header parser * Adjust issues introduced by codemod Almost all all stylistic lint rules. Minority is real issues (e.g. not actually using React, reference types misplaced etc) * Backwards compatible scoped JSX * Use scoped JSX everywhere * Fix augmentations for deprecated namespace * [react-blessed] Actually augment React's JSX namespace * Remove global JSX namespace The goal of just adding the scoped namespace was to ensure the ecosystem can prepare. However, you'd still have to change augmentations to target the scoped namespace i.e. making this a breaking change. So if we break anyway, we might break everything. The additional breakage is codemoddable after all. * Reintroduce global namespace This makes the change fully backwards compatible. Global JSX augmentations still work. Scoped JSX augmentations will work. Everybody can start moving to the scoped JSX if they ensure they're on the latest types/react release for their supported SemVer major. * Revert changes using new scoped JSX namespace That way we can see in the branch diff of this PR that the change is backwards compatible (excluding libraries relying on buggy behavior)). We'll remove usage of the scoped namespace once we landed this change and after a grace period of one week (for integration testing) * Add dedicated test for scoped vs global namespace * [react-blessed] Actually augment React's JSX namespace * Backport to TS 5.0 * Remove duplicate interface declarations * Reduce diff noise --------- Co-authored-by: Mateusz Burzyński <mateuszburzynski@gmail.com>
- Loading branch information
Showing
16 changed files
with
366 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,12 @@ | ||
// Expose `JSX` namespace in `global` namespace | ||
import './'; | ||
import * as React from './'; | ||
|
||
export namespace JSX { | ||
interface Element extends React.JSX.Element {} | ||
interface ElementClass extends React.JSX.ElementClass {} | ||
interface ElementAttributesProperty extends React.JSX.ElementAttributesProperty {} | ||
interface ElementChildrenAttribute extends React.JSX.ElementChildrenAttribute {} | ||
type LibraryManagedAttributes<C, P> = React.JSX.LibraryManagedAttributes<C, P>; | ||
interface IntrinsicAttributes extends React.JSX.IntrinsicAttributes {} | ||
interface IntrinsicClassAttributes<T> extends React.JSX.IntrinsicClassAttributes<T> {} | ||
interface IntrinsicElements extends React.JSX.IntrinsicElements {} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,12 @@ | ||
// Expose `JSX` namespace in `global` namespace | ||
import './'; | ||
import * as React from './'; | ||
|
||
export namespace JSX { | ||
interface Element extends React.JSX.Element {} | ||
interface ElementClass extends React.JSX.ElementClass {} | ||
interface ElementAttributesProperty extends React.JSX.ElementAttributesProperty {} | ||
interface ElementChildrenAttribute extends React.JSX.ElementChildrenAttribute {} | ||
type LibraryManagedAttributes<C, P> = React.JSX.LibraryManagedAttributes<C, P>; | ||
interface IntrinsicAttributes extends React.JSX.IntrinsicAttributes {} | ||
interface IntrinsicClassAttributes<T> extends React.JSX.IntrinsicClassAttributes<T> {} | ||
interface IntrinsicElements extends React.JSX.IntrinsicElements {} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,12 @@ | ||
// Expose `JSX` namespace in `global` namespace | ||
import './'; | ||
import * as React from './'; | ||
|
||
export namespace JSX { | ||
interface Element extends React.JSX.Element {} | ||
interface ElementClass extends React.JSX.ElementClass {} | ||
interface ElementAttributesProperty extends React.JSX.ElementAttributesProperty {} | ||
interface ElementChildrenAttribute extends React.JSX.ElementChildrenAttribute {} | ||
type LibraryManagedAttributes<C, P> = React.JSX.LibraryManagedAttributes<C, P>; | ||
interface IntrinsicAttributes extends React.JSX.IntrinsicAttributes {} | ||
interface IntrinsicClassAttributes<T> extends React.JSX.IntrinsicClassAttributes<T> {} | ||
interface IntrinsicElements extends React.JSX.IntrinsicElements {} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,12 @@ | ||
// Expose `JSX` namespace in `global` namespace | ||
import './'; | ||
import * as React from './'; | ||
|
||
export namespace JSX { | ||
interface Element extends React.JSX.Element {} | ||
interface ElementClass extends React.JSX.ElementClass {} | ||
interface ElementAttributesProperty extends React.JSX.ElementAttributesProperty {} | ||
interface ElementChildrenAttribute extends React.JSX.ElementChildrenAttribute {} | ||
type LibraryManagedAttributes<C, P> = React.JSX.LibraryManagedAttributes<C, P>; | ||
interface IntrinsicAttributes extends React.JSX.IntrinsicAttributes {} | ||
interface IntrinsicClassAttributes<T> extends React.JSX.IntrinsicClassAttributes<T> {} | ||
interface IntrinsicElements extends React.JSX.IntrinsicElements {} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.