This repository has been archived by the owner on May 19, 2018. It is now read-only.
exact object type annotations for Flow plugin #104
Merged
Merged
Changes from 1 commit
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
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
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 |
---|---|---|
|
@@ -322,6 +322,7 @@ export default class Tokenizer { | |
let next = this.input.charCodeAt(this.state.pos + 1); | ||
if (next === code) return this.finishOp(code === 124 ? tt.logicalOR : tt.logicalAND, 2); | ||
if (next === 61) return this.finishOp(tt.assign, 2); | ||
if (code === 124 && next === 125 && this.hasPlugin("flow")) return this.finishOp(tt.braceBarR, 2); | ||
return this.finishOp(code === 124 ? tt.bitwiseOR : tt.bitwiseAND, 1); | ||
} | ||
|
||
|
@@ -404,8 +405,17 @@ export default class Tokenizer { | |
case 44: ++this.state.pos; return this.finishToken(tt.comma); | ||
case 91: ++this.state.pos; return this.finishToken(tt.bracketL); | ||
case 93: ++this.state.pos; return this.finishToken(tt.bracketR); | ||
case 123: ++this.state.pos; return this.finishToken(tt.braceL); | ||
case 125: ++this.state.pos; return this.finishToken(tt.braceR); | ||
|
||
case 123: | ||
if (this.hasPlugin("flow") && this.input.charCodeAt(this.state.pos + 1) == 124) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. (y) |
||
return this.finishOp(tt.braceBarL, 2); | ||
} else { | ||
++this.state.pos; | ||
return this.finishToken(tt.braceL); | ||
} | ||
|
||
case 125: | ||
++this.state.pos; return this.finishToken(tt.braceR); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Needs 2 space indentation. |
||
|
||
case 58: | ||
if (this.hasPlugin("functionBind") && this.input.charCodeAt(this.state.pos + 1) === 58) { | ||
|
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 |
---|---|---|
|
@@ -256,4 +256,4 @@ | |
], | ||
"directives": [] | ||
} | ||
} | ||
} |
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,5 @@ | ||
var a : {| x: number, y: string |} = { x: 0, y: 'foo' }; | ||
var b : {| x: number, y: string, |} = { x: 0, y: 'foo' }; | ||
var c : {| |} = {}; | ||
var d : { a: {| x: number, y: string |}, b: boolean } = { a: { x: 0, y: 'foo' }, b: false }; | ||
var e : {| a: { x: number, y: string }, b: boolean |} = { a: { x: 0, y: 'foo' }, b: false }; |
Oops, something went wrong.
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.
If the
token === tt.braceL
shouldn't the call bethis.flowParseObjectType(false, false);
. It probably doesn't really change anything but it would be more clear maybe (and saves us one comparison in theflowParseObjectType
, although it probably doesn't have an impact.)