[react]: make Component.render() abstract to prevent runtime errors and get better DX#26545
[react]: make Component.render() abstract to prevent runtime errors and get better DX#26545Hotell wants to merge 2 commits intoDefinitelyTyped:masterfrom
Conversation
|
@Hotell Thank you for submitting this PR! 🔔 @me @Kovensky @xbIm @ngbrown @theigor @alitaheri @herrmanno @DaIgeb @allienna @schlesingermatthias @InsidersByte @artyomsv @dan-j @minodisk @samwalshnz @coding2012 @Aaronphy @khanhas @denistirilis @mantasmarcinkus @mattoni @paustint @j-fro @endigo @walkerburgin @vsiao @danilojrr @Batbold-Gansukh @octatone @chengsieuly @mretolaza @katbusch @vitosamson @LKay @aaronbeall @jrakotoharisoa @ianks @kandros @radziksh @Kimahriman @santiagodoldan @alaatm @SupernaviX @KieranPeat @martinnov92 @junbong @uncovertruth @MartynasZilinskas @theruther4d @asvetliakov @abirkholz @ZheyangSong @andrewhathaway @grzesie2k @KostyaEsmukov @GiedriusGrabauskas @chnoch @apare @johnnyreilly - please review this PR in the next few days. Be sure to explicitly select If no reviewer appears after a week, a DefinitelyTyped maintainer will review the PR instead. |
|
@Hotell 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! |
| // $ExpectError | ||
| class MissingRenderer extends React.Component {} | ||
| class MissingRenderer2 extends React.Component { | ||
| // $ExpectError |
There was a problem hiding this comment.
I needed to bump TypeScript version to 2.7 because this test was failing with TS 2.6 no idea why, any suggestions?
With that alt is now failing on CI as it depends on react and TS >= 2.6 .
Any suggestions how to resolve this are more than welcome !
maybe bumping alt to TS 2.7 as well ?
There was a problem hiding this comment.
What's the error that is given when you are using TS <= 2.6?
|
If you bump a definition to a newer TypeScript version, all definitions depending on it need to be upgraded too. |
|
@tkrotoff huh I don't think that's good idea :D ... so maybe we can omit that With that applied:
WDYT ? |
There was a problem hiding this comment.
Good idea; I considered doing it myself before but I ran into some problem and never finished making the PR. I don't remember what it was.
While at it, it could be good to make state optional (readonly state?: Readonly<S>); as using state without initializing it first is an error.
Even calling setState beforehand just to make sure state is initialized doesn't work so well because it'll raise a warning in development builds if state doesn't already exist.
|
@Hotell I haven't seen anything from you in a while and this PR currently has problems that prevent it from being merged. The PR will be closed tomorrow if there aren't new commits to fix the issues. |
|
@Kovensky
I think that belongs to separate PR
|
|
@Hotell 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! |
|
So now I've down graded TS back to 2.6. There are still a lot of errors because various other 3rd party ambient types as they don't implement render... I'm not sure what's the best practice here... should I go through whole repo and fix every 3rd party type definition that uses react ? :-/ |
|
We would have no choice but to fix all of the dependent type defs if we wanted to turn |
right, I will have to write some script with codemod..., doing it by hand sounds like a lot of unnecessary work. If anyone knows about some existing solution/lib to write this kind of codemods I'm all ears |
|
@Hotell Unfortunately, this pull request currently has a merge conflict 😥. Please update your PR branch to be up-to-date with respect to master. Have a nice day! |
|
@Hotell - It appears Travis did not correctly run on this PR! /cc @RyanCavanaugh to investigate and advise. |
f9c0e10 to
8418071
Compare
|
I've udpated whole definitelyTyped repo ( all react depended type definitiopns), although Travis is still failing. It would be nice to resolve this soon and get this merged. Updating 5000+ files is not fun.... |
|
@Hotell 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! |
|
@Hotell 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! |
|
I'm hesitant to merge because Travis is failing... |
|
I know right ! can't you somehow "reboot the build" ? :) |
|
Rebooted. Lots of these errors: |
|
hmm I wonder what those errors come from/what does they mean 😫 any ides @RyanCavanaugh @sandersn ? |
|
The change touches a lot of files, and the tester is failing processing the diffs. Why are we making this change? this seems to be a lot of churn for very little value.. |
|
While I know the change is correct, I think @mhegazy has a good intuition here; the pain may not be worth the benefit. Ideally |
|
Yeah I rather agree with @DanielRosenwasser - the change is correct, but I don't feel it gains us a great deal... |
|
I've checkout branch In order to fix child_process_1.exec(cmd, { encoding: "utf8", cwd, maxBuffer: 1024 * 1024 * 1 /* Max: 1 MiB */ }, ...Documentation here: https://nodejs.org/api/child_process.html#child_process_child_process_exec_command_options_callback btw, Once
The I'm in favor for this PR: if someone issues a PR with improvements, we should support him. @Hotell put a lot of work in this, let's fix the "platform" to help him (it will eventually also help future PRs). |
That's a fairly convincing argument @tkrotoff 😄 Would you like to apply your suggested changes to fix the platform? They sound like improvements DT would feel the benefit of... |
|
@tkrotoff the test issue is rather orthogonal. we should fix it to avoid it happening again. A PR to types-publisher would be appreciated. Now for the current PR. I still believe the value added by this change does not warrant the cost (breaking changes to react users). |
Hey @mhegazy, as far as I know this PR should not cause breaking changes to React users. The only users who would be broken are people that have components which lack a @Hotell has another PR which does represent breaking changes to React users which I'm more hesitant to recommend. But if @tkrotoff's changes mean that the tests pass successfully I can't think of any reason this PR shouldn't get merged. It's possible I've missed something you've picked up on, is there any other reason you can think of that this shouldn't get merged assuming tests pass? |
|
@Hotell To keep things tidy, we have to close PRs that aren't mergeable but don't have activity from their author. No worries, though - please open a new PR if you'd like to continue with this change. Thank you! |
|
Hey Im on vacation so afk sorry for no response, sad to see this closed though... What @johnnyreilly said. If someone's is missing render -> his app will throw on runtime anyway. Only potential "breaking change" could be for js libs authors that have manually written .d.ts ( all they need to do is write down render, 10 seconds effort ). I wanna start working on some codemods for things like this as definitely typed doesn't have semver in it's dictionary 😪 |
|
types-publisher PR for bad @typescript-bot |
|
What surprised me is that making |

Please fill in this template.
npm test.)npm run lint package-name(ortscif notslint.jsonis present).Select one of these and delete the others:
If changing an existing definition:
tslint.jsoncontaining{ "extends": "dtslint/dt.json" }.Creating component via
Component/PureComponentwithout render is invalid and will result in runtime error. Because of that TS should mirror this behaviour on compile time level and improve DX and runtime errors.Pure JS

TS
