Skip to content
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

Wrap type-only class fields in flow comments #11096

Merged
merged 2 commits into from Feb 9, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions packages/babel-parser/src/parser/expression.js
Expand Up @@ -45,6 +45,7 @@ import { ExpressionErrors } from "./util";

export default class ExpressionParser extends LValParser {
// Forward-declaration: defined in statement.js
/*::
+parseBlock: (
allowDirectives?: boolean,
createNewLexicalScope?: boolean,
Expand All @@ -63,6 +64,7 @@ export default class ExpressionParser extends LValParser {
) => T;
+parseFunctionParams: (node: N.Function, allowModifiers?: boolean) => void;
+takeDecorators: (node: N.HasDecorators) => void;
*/

// Check if property __proto__ has been used more than once.
// If the expression is a destructuring assignment, then __proto__ may appear
Expand Down
4 changes: 3 additions & 1 deletion packages/babel-parser/src/parser/index.js
@@ -1,7 +1,7 @@
// @flow

import type { Options } from "../options";
import type { File, JSXOpeningElement } from "../types";
import type { File /*::, JSXOpeningElement */ } from "../types";
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is needed otherwise ESLint marks it as unused (because it's "used" inside a comment).

import type { PluginList } from "../plugin-utils";
import { getOptions } from "../options";
import StatementParser from "./statement";
Expand All @@ -13,9 +13,11 @@ export type PluginsMap = Map<string, { [string]: any }>;

export default class Parser extends StatementParser {
// Forward-declaration so typescript plugin can override jsx plugin
/*::
+jsxParseOpeningElementAfterName: (
node: JSXOpeningElement,
) => JSXOpeningElement;
*/

constructor(options: ?Options, input: string) {
options = getOptions(options);
Expand Down
3 changes: 3 additions & 0 deletions packages/babel-parser/src/parser/location.js
Expand Up @@ -10,7 +10,10 @@ import CommentsParser from "./comments";
// message.

export default class LocationParser extends CommentsParser {
// Forward-declaration: defined in tokenizer/index.js
/*::
+isLookahead: boolean;
*/

getLocationForPosition(pos: number): Position {
let loc;
Expand Down
10 changes: 7 additions & 3 deletions packages/babel-parser/src/parser/lval.js
Expand Up @@ -6,13 +6,13 @@ import type {
TSParameterProperty,
Decorator,
Expression,
Identifier,
Node,
ObjectExpression,
ObjectPattern,
Pattern,
RestElement,
SpreadElement,
/*:: Identifier, */
/*:: ObjectExpression, */
/*:: ObjectPattern, */
} from "../types";
import type { Pos, Position } from "../util/location";
import {
Expand All @@ -31,6 +31,7 @@ const unwrapParenthesizedExpression = (node: Node) => {

export default class LValParser extends NodeUtils {
// Forward-declaration: defined in expression.js
/*::
+parseIdentifier: (liberal?: boolean) => Identifier;
+parseMaybeAssign: (
noIn?: ?boolean,
Expand All @@ -42,8 +43,11 @@ export default class LValParser extends NodeUtils {
isPattern: boolean,
refExpressionErrors?: ?ExpressionErrors,
) => T;
*/
// Forward-declaration: defined in statement.js
/*::
+parseDecorator: () => Decorator;
*/

// Convert existing expression atom to assignable pattern
// if possible.
Expand Down
2 changes: 2 additions & 0 deletions packages/babel-parser/src/tokenizer/index.js
Expand Up @@ -111,7 +111,9 @@ export class Token {
export default class Tokenizer extends LocationParser {
// Forward-declarations
// parser/util.js
/*::
+unexpected: (pos?: ?number, messageOrType?: string | TokenType) => empty;
*/

isLookahead: boolean;

Expand Down
2 changes: 1 addition & 1 deletion packages/babel-parser/src/util/scope.js
Expand Up @@ -92,7 +92,7 @@ export default class ScopeHandler<IScope: Scope = Scope> {
return new Scope(flags);
}
// This method will be overwritten by subclasses
+createScope: (flags: ScopeFlags) => IScope;
/*:: +createScope: (flags: ScopeFlags) => IScope; */

enter(flags: ScopeFlags) {
this.scopeStack.push(this.createScope(flags));
Expand Down