-
Notifications
You must be signed in to change notification settings - Fork 30.5k
Description
Edit: We're likely not doing that in 17 but 18 to make the 17 upgrade as easy as possible. See #46691 (comment) for more context.
Among active contributors we talked informally about making some breaking changes to @types/react in an upcoming major release of React that we think will improve the typings long-term. Now that a release candidate for React 17 is available we should formalize what breaking changes we want to make.
GitHub issues is not the best place for discussing umbrella topics (no threading) but hopefully this will do.
breaking changes
- remove
@deprecatedtypes
These can be flagged intslint-
ReactType(Replace deprecated ReactType with ElementType #56049, [react] Replace deprecated ReactType in favor of ElementType #56396) -
SFCElement([react] Replace deprecated SFCElement in favor of FunctionComponentElement #56397) -
SFCFactory(currently no usage in published@types/packages) -
SFC(Replace deprecated SFC with FunctionComponent #56052, [react] Replace deprecated SFC with FC #56402) -
StatelessComponent([react] Replace deprecated StatelessComponent in favor of FunctionComponent #56399) -
RefForwardingComponent(Accidental usage removed in [carbon-components-react]Checkboxaccepts aref#56414 which shows how the old name looks right but is most likely misused) -
Props([react] Inline usage of deprecated React.Props #56416)
-
- remove implicitly typed
childrenfromReact.FC(and the corresponding overload ofReact.memo)
In TypeScript it's generally easier to add types than remove them.
Closes [React] React.FC doesn't allow bare return of children #33006
Closes [@types/react] Alternative FunctionComponent without children #34237 - Require TypeScript 3.?
Depending on the time frame we should align with the default supported version in DefinitelTyped. From the usage stats in VSCode these older TypeScript versions are rarely used.
Using TypeScript 3.x would allow us to replaceanywithunknownwhich is probably the change with the biggest impact. Removeevent.persist()?- Remove
{}fromReactFragment([react] Remove {} from ReactFragment #56026) -
this.contextwill beunknown
@gaearon Should we hold off with removing deprecated React features? We currently flag the following features as deprecated:
- deprecated lifecycles (cWM, cWRP, cWU,
UNSAFE_prefixed lifecycles)
Maybe removing the unprefixed ones is a viable migration path? - class component constructors with context as the second argument
- class components
this.refsi.e. string refs
features
Already part of next.d.ts
How to go about it?
See #46690 where we can test the approaches. Ideally @types would understand pre-releases but I couldn't find documentation about it so we have to be practical about the approach chosen.
@types/react authors
@johnnyreilly, @bbenezech, @pzavolinsky, @digiguru, @ericanderson, @DovydasNavickas, @theruther4d, @guilhermehubner, @ferdaber, @jrakotoharisoa, @pascaloliv, @Hotell, @franklixuefei, @Jessidhia, @saranshkataria, @lukyth, @eps1lon, @zieka, @dancerphil, @dimitropoulos, @disjukr, @vhfmag, @hellatan