This repository has been archived by the owner on May 19, 2018. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 256
Enable type-checking in src #393
Closed
Closed
Changes from 4 commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
29c888b
Enable type-checking in src
2dcf4d2
Clean up comments
203a898
Fix lint error
f1345d8
Specify type of `strictMode`
0d1b8e4
Remove broken overload
cb5e2b4
`Node` constructor takes non-null arguments, and replace `$FlowCast` …
3aede41
Undo unnecessary change
fa4db25
Remove TODO comment (spec fixed by #406)
ea797ec
Fix recursive type
2ea4c97
Merge branch 'master' into type-check
5c9a2ac
Merge remote-tracking branch 'upstream/master' into type-check
ba87342
Merge branch 'master' into type-check
d7cc741
Merge branch 'master' into type-check
9d430de
Fix type of parseConditional
0b8a2fb
Merge branch 'master' into type-check
a1ecbec
Do not apply plugins to the instance, create a plugin-applied class a…
0dd3b8a
Handle undefined options
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 |
---|---|---|
|
@@ -2,5 +2,8 @@ | |
"extends": "babel", | ||
"env": { | ||
"node": true | ||
}, | ||
"rules": { | ||
"indent": 0 | ||
} | ||
} |
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
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 |
---|---|---|
|
@@ -25,20 +25,20 @@ | |
*/ | ||
|
||
import Parser from "./index"; | ||
import * as N from "../types"; | ||
|
||
function last(stack) { | ||
function last<T>(stack: $ReadOnlyArray<T>): T { | ||
return stack[stack.length - 1]; | ||
} | ||
|
||
const pp = Parser.prototype; | ||
|
||
pp.addComment = function (comment) { | ||
Parser.mixin(class extends Parser { | ||
addComment(comment: N.Comment): void { | ||
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. You can omit annotations if you don't export class or function 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. Some of them could be omitted, but I've tested around and some of them can't without breaking compilation. I also think it's nice to have the type annotations locally so I don't have to look them up in |
||
if (this.filename) comment.loc.filename = this.filename; | ||
this.state.trailingComments.push(comment); | ||
this.state.leadingComments.push(comment); | ||
}; | ||
} | ||
|
||
pp.processComment = function (node) { | ||
processComment(node: N.Node): void { | ||
if (node.type === "Program" && node.body.length > 0) return; | ||
|
||
const stack = this.state.commentStack; | ||
|
@@ -128,10 +128,8 @@ pp.processComment = function (node) { | |
// that comes after the node. Keep in mind that this could | ||
// result in an empty array, and if so, the array must be | ||
// deleted. | ||
node.leadingComments = this.state.leadingComments.slice(0, i); | ||
if ((node.leadingComments: Array<any>).length === 0) { | ||
node.leadingComments = null; | ||
} | ||
const leadingComments = this.state.leadingComments.slice(0, i); | ||
node.leadingComments = leadingComments.length === 0 ? null : leadingComments; | ||
|
||
// Similarly, trailing comments are attached later. The variable | ||
// must be reset to null if there are no trailing comments. | ||
|
@@ -153,4 +151,5 @@ pp.processComment = function (node) { | |
} | ||
|
||
stack.push(node); | ||
}; | ||
} | ||
}); |
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.
Why did you disable this rule? Where there problems with it?
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 I indent things correctly, this PR will have an unreadable diff because the indent of most lines will change. Don't know a good solution for that.
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? Wasn't it properly indented before?
Edit: Ah I see the mixin part. Nice catch. Yes we can enable and autofix later
👍