Port katex, buildTree, parseTree to @flow. (#989)

This commit is contained in:
Ashish Myles
2017-11-25 22:10:14 -05:00
committed by Kevin Barabash
parent dc0c3970c2
commit 1d8cf3fa08
4 changed files with 35 additions and 9 deletions

View File

@@ -6,7 +6,7 @@
import utils from "./utils";
type SettingsOptions = {
export type SettingsOptions = {
displayMode?: boolean;
throwOnError?: boolean;
errorColor?: string;

View File

@@ -1,3 +1,4 @@
// @flow
import buildHTML from "./buildHTML";
import buildMathML from "./buildMathML";
import buildCommon from "./buildCommon";
@@ -5,7 +6,14 @@ import Options from "./Options";
import Settings from "./Settings";
import Style from "./Style";
const buildTree = function(tree, expression, settings) {
import type ParseNode from "./ParseNode";
import type domTree from "./domTree";
const buildTree = function(
tree: ParseNode[],
expression: string,
settings: Settings,
): domTree.span {
settings = settings || new Settings({});
let startStyle = Style.TEXT;

View File

@@ -1,3 +1,4 @@
// @flow
/**
* Provides a single function for parsing an expression using a Parser
* TODO(emily): Remove this
@@ -5,10 +6,13 @@
import Parser from "./Parser";
import type ParseNode from "./ParseNode";
import type Settings from "./Settings";
/**
* Parses an expression using a Parser, then returns the parsed result.
*/
const parseTree = function(toParse, settings) {
const parseTree = function(toParse: string, settings: Settings): ParseNode[] {
if (!(typeof toParse === 'string' || toParse instanceof String)) {
throw new TypeError('KaTeX can only parse string typed expression');
}