Skip to content
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

Upgrade flow; solidify Record and RecordInstance a bit #1276

Merged
merged 1 commit into from
Sep 29, 2017

Conversation

rsolomon
Copy link
Contributor

@rsolomon rsolomon commented Jul 22, 2017

This pull request aims to help out a bit with issues #1240 and #1172 . It does 3 things:

  1. Exposes RecordInstance for import
  2. Changes the return type of some chainable functions to return this & T instead of just this
  3. Uses the new $ElementType<T, K> for some better type safety

Note that I cannot seem to get $ElementType<T, K> to check set properly, but it works fine for get. I really don't know why it wouldn't work the same, so any assistance would be appreciated.

@facebook-github-bot
Copy link

Thank you for your pull request and welcome to our community. We require contributors to sign our Contributor License Agreement, and we don't seem to have you on file. In order for us to review and merge your code, please sign up at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need the corporate CLA signed.

If you have received this in error or have any questions, please contact us at cla@fb.com. Thanks!

@facebook-github-bot
Copy link

Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Facebook open source project. Thanks!

@skeet70
Copy link

skeet70 commented Aug 7, 2017

Can someone please merge this before releasing 4.0? Can confirm that even just exporting RecordInstance alone solves all our project's issues with code like:

type StateT = Record<{
  reportData: Map<string, List<Object>>,
  loadingSummary: boolean,
  loadingReport: boolean
}>;
const State = Record({
  reportData: Map(),
  loadingSummary: false,
  loadingReport: false
});

when changed to:

import type { RecordInstance } from 'immutable';

type StateT = RecordInstance<{
  reportData: Map<string, List<Object>>,
  loadingSummary: boolean,
  loadingReport: boolean
}>;
const State = Record({
  reportData: Map(),
  loadingSummary: false,
  loadingReport: false
});

@nanot1m
Copy link

nanot1m commented Sep 6, 2017

About set look here facebook/flow#4804. There is a workaround

@leebyron leebyron merged commit c28fc9b into immutable-js:master Sep 29, 2017
@leebyron
Copy link
Collaborator

Solid improvements, thanks for the help!

@acusti acusti mentioned this pull request Oct 2, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants