-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Flow: Record: Fix created class types #1193
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Change definition for Record where constructor was specified with 'new'.
Makes Record return a Class type instead of an interface. Fixes an issue with constructor calls.
There was an in-between step when constructing Records. Records now directly return a RecordClass that's the former RecordInstance.
It was overriding RecordClass' generic signature.
@oreqizer This solution works a lot better for me. The downside is it requires making a dummy instance of RecordClass for
Semantically it makes sense that a record class is different than an instance of it, but it makes the code a little awkward. Still, better than before where I had to create my own intersection type from RecordInstance to get this to work. I've been trying to come up with a clean solution myself, but haven't so far. |
Whats stopping this from being released? It looks like a reasonable approach. |
@leebyron, are you agree with this approach? =) |
One unfortunate issue with this approach is that while it technically allows you to use That might be fine, but it's a limitation. I'm going to amend this PR to also include a |
Squashed commit of the following: commit 1d9f98adc72f40754c6a8a10e68a21388254302e Author: Travis CI <[email protected]> Date: Fri Sep 29 17:37:08 2017 -0700 Rename RecordClass to RecordInstance and include RecordOf commit a5c82d59d5b172e658cf1dcf099e0fe601910f36 Merge: cf17600 1f66a82 Author: Travis CI <[email protected]> Date: Fri Sep 29 16:26:48 2017 -0700 Merge branch 'master' of https://github.com/oreqizer/immutable-js into oreqizer-master commit 1f66a82 Author: oreqizer <[email protected]> Date: Thu Mar 30 19:13:18 2017 +0200 feat(flow): Add more tests for Record constructor commit f0addf8 Author: oreqizer <[email protected]> Date: Thu Mar 30 19:11:11 2017 +0200 feat(flow): Add test for Record constructor commit 54d4025 Author: oreqizer <[email protected]> Date: Thu Mar 30 19:10:37 2017 +0200 fix(flow): Remove <T> in constructors It was overriding RecordClass' generic signature. commit 94a54a0 Author: oreqizer <[email protected]> Date: Thu Mar 30 19:02:26 2017 +0200 refactor(flow): Directly return RecordClass There was an in-between step when constructing Records. Records now directly return a RecordClass that's the former RecordInstance. commit ec1a4a6 Author: oreqizer <[email protected]> Date: Thu Mar 30 18:31:00 2017 +0200 fix(flow): Record returns a Class<T> Makes Record return a Class type instead of an interface. Fixes an issue with constructor calls. commit 51c0e97 Author: Boris <[email protected]> Date: Thu Mar 30 17:38:03 2017 +0200 fix(flow): Change 'new' to 'constructor' Change definition for Record where constructor was specified with 'new'.
Specifically check out https://github.com/facebook/immutable-js/blob/master/type-definitions/tests/record.js#L66-L83 for how this ends up affecting the ability to type Records |
Squashed commit of the following: commit 1d9f98adc72f40754c6a8a10e68a21388254302e Author: Travis CI <[email protected]> Date: Fri Sep 29 17:37:08 2017 -0700 Rename RecordClass to RecordInstance and include RecordOf commit a5c82d59d5b172e658cf1dcf099e0fe601910f36 Merge: cf17600 1f66a82 Author: Travis CI <[email protected]> Date: Fri Sep 29 16:26:48 2017 -0700 Merge branch 'master' of https://github.com/oreqizer/immutable-js into oreqizer-master commit 1f66a82 Author: oreqizer <[email protected]> Date: Thu Mar 30 19:13:18 2017 +0200 feat(flow): Add more tests for Record constructor commit f0addf8 Author: oreqizer <[email protected]> Date: Thu Mar 30 19:11:11 2017 +0200 feat(flow): Add test for Record constructor commit 54d4025 Author: oreqizer <[email protected]> Date: Thu Mar 30 19:10:37 2017 +0200 fix(flow): Remove <T> in constructors It was overriding RecordClass' generic signature. commit 94a54a0 Author: oreqizer <[email protected]> Date: Thu Mar 30 19:02:26 2017 +0200 refactor(flow): Directly return RecordClass There was an in-between step when constructing Records. Records now directly return a RecordClass that's the former RecordInstance. commit ec1a4a6 Author: oreqizer <[email protected]> Date: Thu Mar 30 18:31:00 2017 +0200 fix(flow): Record returns a Class<T> Makes Record return a Class type instead of an interface. Fixes an issue with constructor calls. commit 51c0e97 Author: Boris <[email protected]> Date: Thu Mar 30 17:38:03 2017 +0200 fix(flow): Change 'new' to 'constructor' Change definition for Record where constructor was specified with 'new'.
Squashed commit of the following: commit 1d9f98adc72f40754c6a8a10e68a21388254302e Author: Travis CI <[email protected]> Date: Fri Sep 29 17:37:08 2017 -0700 Rename RecordClass to RecordInstance and include RecordOf commit a5c82d59d5b172e658cf1dcf099e0fe601910f36 Merge: cf17600 1f66a82 Author: Travis CI <[email protected]> Date: Fri Sep 29 16:26:48 2017 -0700 Merge branch 'master' of https://github.com/oreqizer/immutable-js into oreqizer-master commit 1f66a82 Author: oreqizer <[email protected]> Date: Thu Mar 30 19:13:18 2017 +0200 feat(flow): Add more tests for Record constructor commit f0addf8 Author: oreqizer <[email protected]> Date: Thu Mar 30 19:11:11 2017 +0200 feat(flow): Add test for Record constructor commit 54d4025 Author: oreqizer <[email protected]> Date: Thu Mar 30 19:10:37 2017 +0200 fix(flow): Remove <T> in constructors It was overriding RecordClass' generic signature. commit 94a54a0 Author: oreqizer <[email protected]> Date: Thu Mar 30 19:02:26 2017 +0200 refactor(flow): Directly return RecordClass There was an in-between step when constructing Records. Records now directly return a RecordClass that's the former RecordInstance. commit ec1a4a6 Author: oreqizer <[email protected]> Date: Thu Mar 30 18:31:00 2017 +0200 fix(flow): Record returns a Class<T> Makes Record return a Class type instead of an interface. Fixes an issue with constructor calls. commit 51c0e97 Author: Boris <[email protected]> Date: Thu Mar 30 17:38:03 2017 +0200 fix(flow): Change 'new' to 'constructor' Change definition for Record where constructor was specified with 'new'.
…ings * facebook/master: (48 commits) 4.0.0-rc.3 Use latest immutable.js build on website Only build docs on tagged releases (immutable-js#1321) Relicense as MIT (immutable-js#1320) Fix rendering issue on tall screens Merge immutable-js#1285 Do not throw from hasIn (immutable-js#1319) Add more flow tests for Records Upgrade prettier and jest (immutable-js#1318) Merge immutable-js#1193 Minor flow record fixes Merges immutable-js#1195 fixed immutable-js#1290 by removing relative position from star count (immutable-js#1317) Fix deploy script Adds a script which automatically builds a #npm branch (immutable-js#1316) Use .github directory Merges immutable-js#1314 Flow config ignore all node_modules Update to latest version of flow (immutable-js#1312) fixed immutable-js#1313 by fixing two borked reducers (immutable-js#1315) ...
Change definition for Record where constructor was specified with 'new'.