-
Notifications
You must be signed in to change notification settings - Fork 43
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
Add Flow Type Support #57
Conversation
Examples/JS/flow/ImageType.js
Outdated
// DO NOT EDIT - EDITS WILL BE OVERWRITTEN | ||
// @generated | ||
// | ||
// @flow |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this work? I think Flow only looks at the first 10 tokens in a file by default. (Might want to move // @flow
to the top just in case)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just for reference, what does @flow
do for us?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// @flow
tells Flow to typecheck the file. Otherwise it will ignore it and assume everything coming out of it is any
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In my testing it works but I will move it to the top.
Examples/JS/flow/ImageType.js
Outdated
import type { PlankDate, PlankURI } from "./runtime.flow.js"; | ||
|
||
|
||
export type ImageType = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should this be an exact object type?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changed!
Examples/JS/flow/PinType.js
Outdated
|
||
export type PinType = { | ||
+note?: string | null, | ||
+media?: { [string]: string } | null, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The contents of media
, counts
, etc should be read-only as well: +media?: { +[string]: string }
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Read only?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, thanks :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated
Can you also generate an import type { BoardType, ImageType } from 'plank-schemas'; instead of import type { BoardType } from 'plank-schemas/BoardType';
import type { ImageType } from 'plank-schemas/ImageType'; Also, make sure this |
Try to use A few more nits:
If you want, you can try running prettier on your output. |
import type { ImageType } from './ImageType.js'; | ||
|
||
export type BoardType = $Shape<{| | ||
+name: ?string, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should there be an id
field on all these objects?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
update: I think there has to be, since a lot of our JS code depends on id
being a field on pins, boards, users, etc.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just pushed a commit that added support for an id field.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need to update any of the CLI help command?
Utility/integration-test.sh
Outdated
@@ -6,6 +6,9 @@ JSON_FILES=`ls -d Examples/PDK/*.json` | |||
# Generate Objective-C models | |||
.build/debug/plank --output_dir=Examples/Cocoa/Sources/objc/ $JSON_FILES | |||
|
|||
#Generate flow types for models | |||
.build/debug/plank --lang flow --output_dir=Examples/JS/flow/ $JSON_FILES |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is there anything we can run to validate these are correct flow definitions since they are not compiled?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can add a .flowconfig
to the JS repo and run flow-bin
CLI command over the output. We need to check if flow-bin
is available globally on the dev's machine though.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just did that. I added plain .flowconfig
file for now to the example folder and run flow on the directory if flow is globally installed.
@rahul-malik We could add some comment to the
|
Before you land this, could you add documentation for the website? @rmalik we will need to change the tag line of the project whenever an official release is cut. |
@rahul-malik Ready for next review. As we talked about yesterday we should treat the flow support as experimental for now. Therefore I moved adding documentation as well as some other non blocking improvements like creating an |
🚫 CI failed with log |
🚫 CI failed with log |
Generated by 🚫 Danger |
@maicki - Did you want to resolve the 2-space implementation within this patch or follow up? |
@rahul-malik I'm currently working on a separate branch that will integrate dynamic indentation support to plank and I will get up a PR soon. In my opinion for this PR it's not necessary and would just bloat up the diff. |
@rahul-malik PR for adding custom indentation support: #61 |
Further details #56
TODOs:
id
fieldFollow Up (No blocker):