Added Flow Typing #778
No reviewers
Labels
No labels
accessibility
app-parity
area: creator
area: daemon
area: design
area: devops
area: discovery
area: docs
area: installer
area: internal
area: livestream
area: performance
area: proposal
area: reposts
area: rewards
area: search
area: security
area: subscriptions
area: sync
area: ux
area: viewer
area: wallet
BEAMER
channel
comments
community PR
consider soon
core team
css
dependencies
electron
Epic
feature request
first-timers-only
good first issue
hacktoberfest
help wanted
hub-dependent
icebox
Invalid
level: 0
level: 1
level: 2
level: 3
level: 4
merge when green
needs: exploration
needs: grooming
needs: priority
needs: repro
needs: tech design
notifications
odysee
on hold
playlists
priority: blocker
priority: high
priority: low
priority: medium
protocol dependent
recsys
redesign
regression
resilience
sdk dependent
Tom's Wishlist
trending
type: bug
type: discussion
type: improvement
type: new feature
type: refactor
type: task
type: testing
unplanned
windows
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference: LBRYCommunity/lbry-desktop#778
Loading…
Add table
Reference in a new issue
No description provided.
Delete branch "flowtype"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Not ready for review yet
Allow background flow daemon to run w/o webpack integration (crossing out because I am waiting until watch.sh refactor is completed)@ -0,0 +20,4 @@
function flowErrorCode(status) {
var error;
switch (status) {
Maybe add a link to flow docs for each of these cases?
@ -0,0 +75,4 @@
function checkFlowStatus(compiler, next) {
var res = spawnSync(flow, store.flowOptions);
I think we should try to use
let
andconst
to show if a variable will change or notComments.
thoughts on all upper case for types?
Any particular reason are these optional properties that we don't set on
defaultState
? IMO optional properties should generally be avoided.(also, state types will generally need to be exported so they can be used by selectors)
Isn't this just
?string
Isn't this an unsealed
Object
ornull
? (not clear on Flow syntax for this:?{}
?)If this is the return value for an interval call, I believe it is
?number
I don't remember what's put in this but I'm just hating on all of your usage of
mixed
at this point.@ -14,3 +44,3 @@
upgradeSkipped: sessionStorage.getItem("upgradeSkipped"),
upgradeSkipped: sessionStorage.getItem("upgradeSkipped") === "true",
daemonVersionMatched: null,
daemonReady: false,
Can you clarify this change?
(And btw, we want to be killing this storage pattern)
We should have an
action
typeI believe mixed is the correct way for to indicate Object
Also also, this should be a sealed object.
optional properties can be thought of as implicitly there, but set to "undefined". I am more than happy to add them, though.
The one edge case I could see, and I will double check this, is, as I was saying in slack:
downloadProgress?: number could be a number or undefined
downloadProgress: ?number could be a number or undefined or null
In order to remove optional fields, we would have to either allow null or determine a non-null default value for each field.
me too, i'll figure it out
I agree, I meant to bring this up, we also need to figure out how to properly do naming.
@ -0,0 +75,4 @@
function checkFlowStatus(compiler, next) {
var res = spawnSync(flow, store.flowOptions);
this file contains code from another repo, I don't want to change it too much because, once they update their npm package, we will be able to use that instead of this file.
ah i didn't realize that, thanks.
@ -14,3 +44,3 @@
upgradeSkipped: sessionStorage.getItem("upgradeSkipped"),
upgradeSkipped: sessionStorage.getItem("upgradeSkipped") === "true",
daemonVersionMatched: null,
daemonReady: false,
sessionStorage.getItem("upgradeSkipped")
returns the string:"true"
so this is, essentailly, casting it to a boolean.yes, thanks
completely agreed, I'm trying to figure that out now
There is some cool stuff we can do with flow and actions, but I also don't want to introduce too much unnecessary boilerplate if its not going to practically help us catch errors
I am going to go through each of these one by one to determine whether or not I can add null, or some other initial value to them instead of undefined, however, there inevitably will be some fields that are initialized as undefined (given what we decided in terms of having no optional types + using undefined as a distinct value). Does this seem alright to you guys? @kauffj @seanyesmunt
Yes, given that the existing behavior a property not explicitly set on
defaultState
is to default toundefined
, it makes sense to set values toundefined
rather thannull
to match existing behavior.Got it. Makes sense. I'm cool with this.
@ -14,3 +44,3 @@
upgradeSkipped: sessionStorage.getItem("upgradeSkipped"),
upgradeSkipped: sessionStorage.getItem("upgradeSkipped") === "true",
daemonVersionMatched: null,
daemonReady: false,
@liamcardenas but this changeset also changes this value from
true
to"true"
.(If you just want to cast, I'd propose either a typical cast of
Boolean(foo)
or!!foo
)Just some questions on the
flowtype-plugin.js
file, but looks good.@ -0,0 +75,4 @@
function checkFlowStatus(compiler, next) {
var res = spawnSync(flow, store.flowOptions);
What is the other module? Seems simple enough, do we need to use it?
@ -14,3 +44,3 @@
upgradeSkipped: sessionStorage.getItem("upgradeSkipped"),
upgradeSkipped: sessionStorage.getItem("upgradeSkipped") === "true",
daemonVersionMatched: null,
daemonReady: false,
I think he's saying no matter how it was stored in
sessionStorage
it was still being returned as"true"
.Using the
!!
operator orBoolean
will still returntrue
for"false"
strings because strings are truthy.@liamcardenas is that right?
@ -14,3 +44,3 @@
upgradeSkipped: sessionStorage.getItem("upgradeSkipped"),
upgradeSkipped: sessionStorage.getItem("upgradeSkipped") === "true",
daemonVersionMatched: null,
daemonReady: false,
that doesn't work, because
Boolean('false')
and!!'false'
evaluate totrue
This is the best way to get a boolean value that is recorded as a string. The alternative would be
JSON.parse(foo)
, but I wouldn't want to be able to introduce arbitrary, non-boolean values.@liamcardenas I do not think that is correct https://flow.org/en/docs/types/mixed/
@ -14,3 +44,3 @@
upgradeSkipped: sessionStorage.getItem("upgradeSkipped"),
upgradeSkipped: sessionStorage.getItem("upgradeSkipped") === "true",
daemonVersionMatched: null,
daemonReady: false,
Wow, sure enough, the Storage API changes the type!
Absolute insanity!
@ -14,3 +44,3 @@
upgradeSkipped: sessionStorage.getItem("upgradeSkipped"),
upgradeSkipped: sessionStorage.getItem("upgradeSkipped") === "true",
daemonVersionMatched: null,
daemonReady: false,
I know, I wouldn't have caught this if flow didn't give me a type error for trying to input/expect booleans where it is supposed to be a string.
That's the beauty of type checking, this could've led to some pretty nasty bugs.
@ -0,0 +75,4 @@
function checkFlowStatus(compiler, next) {
var res = spawnSync(flow, store.flowOptions);
this is a pretty decently maintained package: https://github.com/zhirzh/flow-babel-webpack-plugin
I'd like to be able to include other changes made by that developer if possible. I left an issue about updating the NPM package. If it looks abandoned after enough time then we should look at bringing this in-house. I expect to deprecate this file relatively soon though.
@ -0,0 +75,4 @@
function checkFlowStatus(compiler, next) {
var res = spawnSync(flow, store.flowOptions);
but you're right, if need be it is definitely simple