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 // result in an empty array, and if so, the array must be
// deleted. // deleted.
node.leadingComments = this.state.leadingComments.slice(0, i); node.leadingComments = this.state.leadingComments.slice(0, i);
if (node.leadingComments.length === 0) { if ((node.leadingComments: Array<any>).length === 0) {
node.leadingComments = null; node.leadingComments = null;
} }

View File

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

View File

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

View File

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