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
@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.refs i.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
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/reactin 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
@deprecatedtypesThese can be flagged in
tslintReactType(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)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
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 replace
anywithunknownwhich is probably the change with the biggest impact.Removeevent.persist()?{}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:
UNSAFE_prefixed lifecycles)Maybe removing the unprefixed ones is a viable migration path?
this.refsi.e. string refsfeatures
Already part of
next.d.tsHow to go about it?
See #46690 where we can test the approaches. Ideally
@typeswould understand pre-releases but I couldn't find documentation about it so we have to be practical about the approach chosen.@types/reactauthors@johnnyreilly, @bbenezech, @pzavolinsky, @digiguru, @ericanderson, @DovydasNavickas, @theruther4d, @guilhermehubner, @ferdaber, @jrakotoharisoa, @pascaloliv, @Hotell, @franklixuefei, @Jessidhia, @saranshkataria, @lukyth, @eps1lon, @zieka, @dancerphil, @dimitropoulos, @disjukr, @vhfmag, @hellatan