add some more flow types

This commit is contained in:
Henry Zhu 2015-12-18 01:19:06 -05:00
parent 97fd9d65e7
commit 5f0ece0bdb
4 changed files with 10 additions and 6 deletions

View File

@ -118,7 +118,7 @@ pp.processComment = function (node) {
// result in an empty array, and if so, the array must be
// deleted.
node.leadingComments = this.state.leadingComments.slice(0, i);
if (node.leadingComments.length === 0) {
if ((node.leadingComments: Array<any>).length === 0) {
node.leadingComments = null;
}

View File

@ -1,4 +1,4 @@
/* @noflow */
/* @flow */
import { reservedWords } from "../util/identifier";
import { getOptions } from "../options";
@ -7,7 +7,7 @@ import Tokenizer from "../tokenizer";
export const plugins = {};
export default class Parser extends Tokenizer {
constructor(options, input: string) {
constructor(options: Object, input: string) {
options = getOptions(options);
super(options, input);
@ -31,7 +31,7 @@ export default class Parser extends Tokenizer {
this[name] = f(this[name]);
}
loadPlugins(plugins: Array<string>) {
loadPlugins(plugins: Array<string>): Object {
let pluginMap = {};
if (plugins.indexOf("flow") >= 0) {

View File

@ -26,7 +26,9 @@ export class TokContext {
override: ?Function;
}
export const types = {
export const types: {
[key: string]: TokContext;
} = {
b_stat: new TokContext("{", false),
b_expr: new TokContext("{", true),
b_tmpl: new TokContext("${", true),
@ -57,7 +59,7 @@ tt.parenR.updateContext = tt.braceR.updateContext = function () {
tt.name.updateContext = function (prevType) {
this.state.exprAllowed = false;
if (prevType === tt._let || prevType === tt._const || prevType === tt._var) {
if (lineBreak.test(this.input.slice(this.state.end))) {
this.state.exprAllowed = true;

View File

@ -1,3 +1,5 @@
/* @noflow */
import type { TokenType } from "./types";
import { isIdentifierStart, isIdentifierChar, isKeyword } from "../util/identifier";
import { types as tt, keywords as keywordTypes } from "./types";