-
Notifications
You must be signed in to change notification settings - Fork 64
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 annotations. #51
Closed
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
[ignore] | ||
.*/node_modules/documentation/* | ||
|
||
[libs] | ||
|
||
[include] | ||
|
||
[options] | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
// @flow | ||
|
||
import type { Protocol } from "./protocols-table.js" | ||
|
||
export type Name$Address = [string, string] | ||
export type Code$Buffer = [number, Buffer] | ||
export type { Protocol } | ||
export class ParseError extends Error {} | ||
|
||
declare export default { | ||
stringToStringTuples(string): Name$Address[], | ||
stringTuplesToString(Name$Address[]): string, | ||
tuplesToStringTuples(Code$Buffer[]): Name$Address[], | ||
stringTuplesToTuples(Name$Address[]): Code$Buffer[], | ||
|
||
bufferToTuples(Buffer): Code$Buffer[], | ||
tuplesToBuffer(Code$Buffer[]): Buffer, | ||
|
||
bufferToString(Buffer): string, | ||
stringToBuffer(string): Buffer, | ||
|
||
fromString(string): Buffer, | ||
fromBuffer(Buffer): Buffer, | ||
validateBuffer(mixed): void, | ||
isValidBuffer(mixed): boolean, | ||
cleanPath(string): string, | ||
|
||
ParseError(string): ParseError, | ||
protoFromTuple(Name$Address | Code$Buffer): Protocol, | ||
|
||
sizeForAddr(Protocol, Buffer): number | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
// @flow | ||
|
||
import type { Protocol, Code } from "./protocols-table" | ||
export type { Protocol, Code } | ||
|
||
declare export default { | ||
// So this just flips the type it seems, I wish there were two different named | ||
// functions instead. | ||
(Protocol, Buffer): string, | ||
(Protocol, string): Buffer, | ||
toString(Protocol, Buffer): string, | ||
toBuffer(Protocol, string): Buffer | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
// @flow | ||
|
||
import type { Callback } from "callback.flow" | ||
import type { Protocol, Code } from "./protocols-table" | ||
import protocols from "./protocols-table" | ||
export opaque type String: string = string | ||
export type { Protocol, Code, Callback } | ||
|
||
export type Options = { | ||
family: string, | ||
host: string, | ||
transport: string, | ||
port: string | ||
} | ||
|
||
export type NodeAddress = { | ||
family: string, | ||
address: string, | ||
port: string | ||
} | ||
|
||
export interface Multiaddr { | ||
buffer: Buffer; | ||
toString(): String; | ||
toOptions(): Options; | ||
inspect(): string; | ||
protos(): Protocol[]; | ||
protoCodes(): Code[]; | ||
protoNames(): string[]; | ||
tuples(): Array<[Code, Buffer]>; | ||
stringTuples(): Array<[Code, string | number]>; | ||
encapsulate(string | Buffer | Multiaddr): Multiaddr; | ||
decapsulate(string | Buffer | Multiaddr): Multiaddr; | ||
getPeerId(): ?string; | ||
equals(Multiaddr): boolean; | ||
nodeAddress(): NodeAddress; | ||
isThinWaistAddress(Multiaddr): boolean; | ||
fromStupidString(string): empty; | ||
} | ||
|
||
declare export default { | ||
Buffer: typeof Buffer, | ||
protocols: typeof protocols, | ||
(string | Buffer | Multiaddr): Multiaddr, | ||
fromNodeAddress(NodeAddress, transport: string): Multiaddr, | ||
isMultiaddr(mixed): boolean, | ||
isName(mixed): boolean, | ||
resolve(mixed, Callback<Error, void>): void | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
// @flow | ||
|
||
export opaque type Code: number = number | ||
export type Size = number | ||
|
||
export type Protocol = { | ||
code: Code, | ||
size: Size, | ||
name: string, | ||
resolvable: boolean | ||
} | ||
|
||
declare export default { | ||
(string | number): Protocol, | ||
lengthPrefixedVarSize: number, | ||
V: number, | ||
table: Array<[number, number, string]>, | ||
names: { [string]: Protocol }, | ||
codes: { [number]: Protocol }, | ||
object(Code, Size, string, boolean): Protocol | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
@vmx guessing that these .flowconfig files will be removed in your effort to add flow directly to aegir, correct?
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 don't believe that would be possible given that flow uses .flowconfig to detect the root what needs to be type-checked.
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.
Huh, is there no way for us to specify where the config file is located? Feels very suboptimal if we have to add this to every repository...
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.
As far as I know it's still the case (at least there is no documented parameter to a flow command). Please note that it's not as much of an issue about specifying a config (
.flowconfig
could be a blank file) but rather about not being able to specify a root from which to type-check.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.
@victorbjelkholm I hope to have it go away. @garrensmith will have a look.
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.
Reading here, it doesn't seem like we can remove the flowconfig file. It should be a very simple file for each project. I don't think it would be to much of an issue having it in each repo. We could maybe look at having AEgir generate a generic .flowconfig file for a repo.