add declare to class properties type annotations (#12257)

* add declare to class properties type annotations

* chore: use preset-flow
This commit is contained in:
Huáng Jùnliàng
2020-10-27 10:05:01 -04:00
committed by GitHub
parent 9eb661b285
commit ea2892fefc
14 changed files with 70 additions and 94 deletions

View File

@@ -10,23 +10,23 @@ import type ProductionParameterHandler from "../util/production-parameter";
export default class BaseParser {
// Properties set by constructor in index.js
options: Options;
inModule: boolean;
scope: ScopeHandler<*>;
classScope: ClassScopeHandler;
prodParam: ProductionParameterHandler;
expressionScope: ExpressionScopeHandler;
plugins: PluginsMap;
filename: ?string;
declare options: Options;
declare inModule: boolean;
declare scope: ScopeHandler<*>;
declare classScope: ClassScopeHandler;
declare prodParam: ProductionParameterHandler;
declare expressionScope: ExpressionScopeHandler;
declare plugins: PluginsMap;
declare filename: ?string;
sawUnambiguousESM: boolean = false;
ambiguousScriptDifferentAst: boolean = false;
// Initialized by Tokenizer
state: State;
declare state: State;
// input and length are not in state as they are constant and we do
// not want to ever copy them, which happens if state gets cloned
input: string;
length: number;
declare input: string;
declare length: number;
hasPlugin(name: string): boolean {
return this.plugins.has(name);

View File

@@ -101,11 +101,11 @@ export class Token {
this.loc = new SourceLocation(state.startLoc, state.endLoc);
}
type: TokenType;
value: any;
start: number;
end: number;
loc: SourceLocation;
declare type: TokenType;
declare value: any;
declare start: number;
declare end: number;
declare loc: SourceLocation;
}
// ## Tokenizer

View File

@@ -23,7 +23,7 @@ type raiseFunction = (number, string, ...any) => void;
export default class ClassScopeHandler {
stack: Array<ClassScope> = [];
raise: raiseFunction;
declare raise: raiseFunction;
undefinedPrivateNames: Map<string, number> = new Map();
constructor(raise: raiseFunction) {

View File

@@ -39,8 +39,8 @@ type raiseFunction = (number, string, ...any) => void;
// current scope in order to detect duplicate variable names.
export default class ScopeHandler<IScope: Scope = Scope> {
scopeStack: Array<IScope> = [];
raise: raiseFunction;
inModule: boolean;
declare raise: raiseFunction;
declare inModule: boolean;
undefinedExports: Map<string, number> = new Map();
undefinedPrivateNames: Map<string, number> = new Map();