Port functions.js to @flow. (#867)

* Make types in defineFunction stricter and prep for porting functions.js to flow.

* Add more explicit types to functions/delimsizing.js.

* Port functions.js to @flow.
This commit is contained in:
Ashish Myles
2017-09-10 21:25:36 -04:00
committed by GitHub
parent ceefd4934f
commit d8060ca9b4
4 changed files with 138 additions and 91 deletions

View File

@@ -9,6 +9,9 @@ import utils from "../utils";
import * as html from "../buildHTML";
import * as mml from "../buildMathML";
import type ParseNode from "../ParseNode";
import type {FunctionContext} from "../defineFunction";
// Extra data needed for the delimiter handler down below
const delimiterSizes = {
"\\bigl" : {mclass: "mopen", size: 1},
@@ -45,7 +48,7 @@ const delimiters = [
];
// Delimiter functions
const checkDelimiter = function(delim, context) {
function checkDelimiter(delim: ParseNode, context: FunctionContext): ParseNode {
if (utils.contains(delimiters, delim.value)) {
return delim;
} else {
@@ -53,7 +56,7 @@ const checkDelimiter = function(delim, context) {
"Invalid delimiter: '" + delim.value + "' after '" +
context.funcName + "'", delim);
}
};
}
defineFunction({
type: "delimsizing",