Commit Graph

10 Commits

Author SHA1 Message Date
Ashish Myles
0ac4b6e89d Convert ParseNode to struct (#1534)
* Define the nested version of ParseNodes structs explicitly.

Passes test:jest, but fails test:flow.

* Fix additional type errors reported by flow.

* Migrate rebased code from master.

* Rename ParseNode.js to parseNode.js.

* Update defineEnvironment output type to fix the flow errors in environment/array.js.
2018-08-01 15:41:27 +09:00
Ashish Myles
19d2aa63c3 Replace ParseNode<*> with a more accurate AnyParseNode and fix flow errors. (#1387)
* Replace ParseNode<*> with a more accurate AnyParseNode and fix flow errors.

* Allow "array" environment type spec to use any all symbol type.

Before this commit, it was constrained to use "mathord" and "textord", but a
recent change in HEAD resulted in a "rel" node being used in the spec for, e.g.
\begin{array}{|l||c:r::}\end{array}

* Address reviewer comments: rename `lastRow` to `row` in array.js.
2018-06-04 10:56:51 -04:00
Ashish Myles
e3fb2f95ae Update flow version and address type errors. (#1369) 2018-05-27 16:19:10 -04:00
Ashish Myles
9cde0336d3 Correct (type-wise) raisebox's usage of sizing's buildHtml. (#1361)
* Correct (type-wise) raisebox's usage of sizing's buildHtml.

* Move HTML and MathML groupTypes into defineFunction.

Currently, functions defined in functions/* import all exports from buildHtml
and buildMathML, but they should never use `groupTypes` directly as it loses
type-safety. They should instead use more type-safe `htmlBuilder`s and
`mathmlBuilder`s exported directly from other definitions `functions/*` to allow
flow to catch errors.

* Rename groupTypes to groupBuilders.
2018-05-27 16:24:30 +09:00
Ashish Myles
99b2afa935 Specify flow output types for htmlBuilder and mathmlBuilder. (#1324)
* Specify flow output types for htmlBuilder and mathmlBuilder.

* Add TODOs to refactor to improve the return type of mathmlBuilder.
2018-05-19 02:27:52 +02:00
Ashish Myles
431434258d Make htmlBuilder and mathmlBuilder params type-safe. (#1312)
* Make htmlBuilder and mathmlBuilder params type-safe.

Also correct and refine some of the ParseNode types.
2018-05-17 10:38:48 -04:00
Ashish Myles
5a4aedd882 Make ParseNode value payload and defineFunction handler functions type-safe (#1276)
* Make ParseNode `value` payload type-safe.

* Make defineFunction handlers aware of ParseNode data types.

* Add `type` to all function definitions to help determine handler return type.

* Added unit test for case caught only in screenshot test and fixed issue.

* Rename some symbol `Group`s to avoid conflicts with `ParseNode` groups.

Symbol `Group`s are also used as `ParseNode` types. However, `ParseNode`s of
these types always contain a raw text token as opposed to any structured
content. These `ParseNode`s are passed as arguments into function handlers to
create more semantical `ParseNode`s with more structure.

Before this change, "accent" and "op" were both symbol `Group`s and `ParseNode`
types. With this change, these two types (the raw accent token `ParseNode`, and
the structured semantical `ParseNode` are separated for better type-safety on
the `ParseNode` payload).

* stretchy: Remove FlowFixMe for a forced typecast that's no longer needed.
2018-05-09 20:13:31 -04:00
Kevin Barabash
5cc795eaaa flow typings for parser.js (#1041)
flow typings for parser.js
2017-12-29 13:26:22 -05:00
Ashish Myles
6de5446913 Parser: Separate mandatory and optional arguments in parseArguments (#903)
* Parser: Make parseArguments() more DRY.

* Parser: Separate args and optional args for type strictness.
2017-09-25 20:37:29 -06:00
Kevin Barabash
ca6ea4c580 refactor defineEnvironment to also accept HTML and MathML builders (#875)
* refactor defineEnvironment to also accept HTML and MathML builders, fixes #870

* make argTypes mandatory, remove unused props from EnvProps, use while(true)
2017-09-20 00:05:18 -04:00