mirror of
https://github.com/Smaug123/KaTeX
synced 2025-10-05 03:08:40 +00:00
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.
This commit is contained in:
committed by
Kevin Barabash
parent
3613885da1
commit
5a4aedd882
@@ -407,6 +407,7 @@ describe("A subscript and superscript parser", function() {
|
||||
|
||||
it("should not fail when there is no nucleus", function() {
|
||||
expect("^3").toParse();
|
||||
expect("^3+").toParse();
|
||||
expect("_2").toParse();
|
||||
expect("^3_2").toParse();
|
||||
expect("_2^3").toParse();
|
||||
|
Reference in New Issue
Block a user