Skip to content

[react-router] Improve withRouter definition with conditional types#24586

Closed
Grmiade wants to merge 3 commits into
DefinitelyTyped:masterfrom
Grmiade:feature/grmiade/react-router-improvements
Closed

[react-router] Improve withRouter definition with conditional types#24586
Grmiade wants to merge 3 commits into
DefinitelyTyped:masterfrom
Grmiade:feature/grmiade/react-router-improvements

Conversation

@Grmiade

@Grmiade Grmiade commented Mar 28, 2018

Copy link
Copy Markdown
Contributor

⚠️ We have to wait for a compatibility with the new 2.8 TypeScript version

Thanks to conditional types, withRouter definition excludes injected props only when props is assignable to RouteComponentProps.

Fix #24070

@Grmiade Grmiade requested a review from johnnyreilly as a code owner March 28, 2018 10:04
@Grmiade Grmiade force-pushed the feature/grmiade/react-router-improvements branch from 5cf3191 to 524e3c4 Compare March 28, 2018 10:17
@typescript-bot typescript-bot added Popular package This PR affects a popular package (as counted by NPM download counts). Awaiting reviewer feedback labels Mar 28, 2018
@typescript-bot

typescript-bot commented Mar 28, 2018

Copy link
Copy Markdown
Contributor

@Grmiade Thank you for submitting this PR!

🔔 @Shearerbeard @asvetliakov @seryl @dijimsta @me @grossbart @wereHamster @jgoz @tomwanzek @gustavderdrache @borisyankov @Ledragon @Ledragon @dmitryrogozhny @eelco @ghotiphud @schwers @michael-yx-wu @willisplummer @smvilar @MarianPalkus @NoHomey @jwbay @huhuanming @MartynasZilinskas @thovden @KonstantinKai @martynaskadisa @janaagaard75 @ssanchezmarc @fhelwanger @incleaf @pepaar @stephenjelfs @ilivit @mrk21 @Cobster @atd-schubert @JeffJacobson @honzabrecka @antonvasin @steller @dborysov @leonard-thieu @choffmeister @Steve-Fenton @Diullei @tasoili @jasons-novaleaf @seanski @Guuz @ksummerlin @basarat @nwolverson @derekcicerone @AndrewGaspar @seikichi @benjaminjackman @s093294 @JoshStrobl @johnnyreilly @DickvdBrink @King2500 @stkb @DovydasNavickas @bcherny @cyrilletuzi @alejo90 @dobrud @patrickr @ngbrown @theigor @alitaheri @herrmanno @DaIgeb @allienna @schlesingermatthias @InsidersByte @artyomsv @dan-j @minodisk @coding2012 @aaronphy @grahammendick @stevegeek @alexgorbatchev @nupplaphil @mihe @DenisTirilis @mantasmarcinkus @mattoni @paustint @j-fro @bbenezech @pzavolinsky @digiguru @ericanderson @morcerf @tkrotoff @onigoetz @richseviora @theruther4d @ssyrell @endigo @prakarshpandey @forabi @crohlfs @nicolas-schmitt @pjo256 @robessog @tbayne @cdeutsch @rosskevin @varHarrie @bradleyayers @piotrwitek @pikpok @mhegazy @walkerburgin @vsiao @danilojrr @Batbold-Gansukh @octatone @chengsieuly @mretolaza @katbusch @vitosamson @LKay @aaronbeall @ssi-hu-antal-bodnar @flaub @alelode @UJosue10 @dawnmist @Ogglas @Guymestef @radziksh @KostyaEsmukov @mitsuruog @kandros @9renpoto @screendriver @Kimahriman @markspolakovs @mntdn @santiagodoldan @mabels @BernabeFelix @David-LeBlanc-git @kittimiyo @andrewBalekha @smrq @Rogach @royxue @KoalaHuman @uncovertruth @Artur-A @oizie @gustavohenke @mleko @cleverguy25 @matdube @LynxEyes @goblindegook @benbayard @codeaid @jurosh @eugrdn @patsissons @apare @jankarres @deviousm @senukartur @begincalendar @pushplay @timurrustamov @dublicator @vincaslt @gavingregory @cameron-mcateer @brmenchl @invliD @abirkholz @ZheyangSong @andrewhathaway @grzesie2k @evanbb @isman-usoh @lith-light-g @sammkj @yuit @jacekjagiello @tock203 @GiedriusGrabauskas @chnoch @adamwpc @rhysd @Lapanti @psrebniak @bgrieder @cdroulers @gyzerok @tillwolff @bhouser @kristerkari @formatlos @seansfkelley @DanielRosenwasser @bendxn @spielc @gnestor @iamdanfox @sirreal @iplus26 @KurtPreston @m0a @danzel @davschne @buptyyf @tomshen @artfuldev @lavoaster @CarlosBonetti @morphologue @bradzacher @marcfallows @tkqubo @drewnoakes @homburg @ttamminen @hallowatcher @peterblazejewicz @jnetterf @stepancar @dimitarnestorov @alloy @iRoachie @timwangdev @kamal @nelyousfi @jacobbaskin @jnbt @jmfirth @ifiokjr @egorshulga @PaitoAnderson @connectdotz @plantain-00 @mrand01 @CaiHuan @SahinVardar @sivolobov @mhcgrq @kaoDev @abrahambotros @fangpenlin @petejkim @phanalpha @charlesfamu @bang88 @svbutko @levito @robertohuertasm @YourGamesBeOver @DeividasBakanas @sztobar @heatherbooker @salim7 @jemmyw @deevus @wouterhardeman @pegel03 @archy-bold @istefo @mdibyo @shuntksh @zzanol @thasner @kenzierocks @clayne11 @tansongyang @nicholasboll @pdeva @clementdevos @Smiche @kulmajaba @graphcool @voxmatt @npirotte @alechill @xaviergonz @sergey-buturlakin @vasek17 @awendland @huy-nguyen @neuoy @ezintz @8398a7 @Hesquibet @giladgray @iebaker @skirsdeda @vujevits @devrelm @onatm @ninjaferret @tehbi4 @misantronic @remojansen @jeroenvervaeke @ricokahler @DomiR @r3nya @charlesrey @jzoric @curtisw0 @sonnysangha @mctep @horiuchi @mxl @psakalo @Havret @mykter @arvitaly @lochbrunner @guilhermehubner @zry656565 @shssoichiro @janslow @mattvperry @ccancellieri @bsurai @guntherjh @wasd171 @szabolcsx @kraenhansen @rogierschouten @sanyatuning @frodehansen2 @kgtkr @chrisgervang @Barrokgl @mthmulders @rapmue @richbai90 @iskandersierra @mrapogee @mc-petry @Valbrand @viggyfresh @janb87 @corydeppen @aikoven @carsonf @bancek @alsiola @silkyfray @priecint @SashaBayan @kourge @zmaybury @mkornblum @fyrkant @joscha @jessepinho @wapgear @martinduparc @ipoul @nicohartto @snerks - please review this PR in the next few days. Be sure to explicitly select Approve or Request Changes in the GitHub UI so I know what's going on.

If no reviewer appears after a week, a DefinitelyTyped maintainer will review the PR instead.

@typescript-bot typescript-bot added Author is Owner The author of this PR is a listed owner of the package. The Travis CI build failed labels Mar 28, 2018
@typescript-bot

Copy link
Copy Markdown
Contributor

@Grmiade The Travis CI build failed! Please review the logs for more information. Once you've pushed the fixes, the build will automatically re-run. Thanks!

@Grmiade Grmiade force-pushed the feature/grmiade/react-router-improvements branch from 524e3c4 to e777c4e Compare March 28, 2018 10:26
@Grmiade Grmiade force-pushed the feature/grmiade/react-router-improvements branch from e777c4e to 5219599 Compare March 28, 2018 10:30
@Grmiade

Grmiade commented Mar 28, 2018

Copy link
Copy Markdown
Contributor Author

@johnnyreilly I have this error react-router depends on react but has a lower required TypeScript version.
But if I change the TypeScript version, I will have to change the version in all packages which depends on react 😱 What should I do?

@johnnyreilly

Copy link
Copy Markdown
Member

I think that may be the only course of action I'm afraid. It's not great..

@Grmiade

Grmiade commented Mar 28, 2018

Copy link
Copy Markdown
Contributor Author

screen shot 2018-03-28 at 15 06 52

😓

@johnnyreilly

Copy link
Copy Markdown
Member

Ouch

@Grmiade Grmiade force-pushed the feature/grmiade/react-router-improvements branch from 30332c6 to 80b7a64 Compare March 28, 2018 13:29
@Grmiade Grmiade requested a review from alloy as a code owner March 28, 2018 13:29
@Grmiade Grmiade force-pushed the feature/grmiade/react-router-improvements branch from 80b7a64 to 2110ad6 Compare March 28, 2018 14:05
@Grmiade

Grmiade commented Mar 28, 2018

Copy link
Copy Markdown
Contributor Author

Error: Could not parse version: line is '// TypeScript Version: 2.8'
How resolve this error? We should only update the definitelytyped-header-parser package?

@DanielRosenwasser

DanielRosenwasser commented Mar 28, 2018

Copy link
Copy Markdown
Member

Because of the fact that this would break literally everyone who hasn't upgraded to 2.8, DefinitelyTyped is only compatible with the prior release, and that's enabled by updating the package I think you mentioned.

Comment thread types/jquery/index.d.ts
// Thomas Schulz <https://github.com/King2500>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.3
// TypeScript Version: 2.8

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

jQuery does not have a dependency on React. This version bump should not be necessary.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

react => react-mce => tinymce => jquery 😞
Normally, I updated only packages where a dependency error was raised.
If you have a better solution, I take it 😉

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

react => react-mce => tinymce => jquery 😞

This is the actual dependency graph. Neither @types/jquery or @types/tinymce should require the version bump.

chrome_2018-03-28_14-57-17

Could you double check that jQuery indeed causes the error without the version bump?

It should be the case that only dependents of React need to be updated, not dependencies (@Andy-MS ?).

If it is the case that jQuery requires the version bump, I'd be against this change even when 2.8 becomes allowed on DefinitelyTyped. Increasing requirements soon after a new version becomes allowed seems to cause breaks for a lot of jQuery consumers. It'd be prudent to wait even longer to minimize this.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as the comment above by @leonard-thieu with respect to d3 et al. None of the D3 modules has an external dependency outside the D3 ecosystem, the only exception is GeoJson for a couple of module definitions. There is certainly no dependency on react or react-faux-dom.

As for our current versioning policy, we are migrating the definitions to start using some TS 2.3 features, as the release is ~1yr out and the installed based should be able to adopt readily. TS 2.8 is likely a while out, regardless of how beneficial the new features may be.

@Grmiade Grmiade Mar 28, 2018

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes I confirm @leonard-thieu 😕
I understand your remarks.
This dependency system is blocking :/ Conditional types feature is sooo powerful to fix some issues.

@tomwanzek tomwanzek left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Neither d3 nor any of the d3-xxx module definitions have any dependency on React, so beyond the general point made by @DanielRosenwasser, these definitions do not require a TS 2.8, even if one addressed the React part.

@Grmiade

Grmiade commented Mar 28, 2018

Copy link
Copy Markdown
Contributor Author

react => react-mce => tinymce => jquery 😞
Normally, I updated only packages where a dependency error was raised.
If you have a better solution, I take it 😉

@tomwanzek For d3, the dependency path is react => react-faux-dom => d3

@mhegazy

mhegazy commented Apr 9, 2018

Copy link
Copy Markdown
Contributor

Thanks for your contribution. This PR has failing CI tests and can not be merged in at the time being. For housekeeping purposes we are closing stale PRs. If you'd still like to merge this code in, please open a new PR that has been merged and rebased with the master branch.

@mhegazy mhegazy closed this Apr 9, 2018
@dannycochran dannycochran mentioned this pull request Jul 25, 2018
16 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Author is Owner The author of this PR is a listed owner of the package. Popular package This PR affects a popular package (as counted by NPM download counts).

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants