mirror of
https://github.com/Smaug123/KaTeX
synced 2025-10-17 00:38:39 +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
@@ -17,7 +17,7 @@ const optionsFromSettings = function(settings: Settings) {
|
||||
};
|
||||
|
||||
export const buildTree = function(
|
||||
tree: ParseNode[],
|
||||
tree: ParseNode<*>[],
|
||||
expression: string,
|
||||
settings: Settings,
|
||||
): DomSpan {
|
||||
@@ -39,7 +39,7 @@ export const buildTree = function(
|
||||
};
|
||||
|
||||
export const buildHTMLTree = function(
|
||||
tree: ParseNode[],
|
||||
tree: ParseNode<*>[],
|
||||
expression: string,
|
||||
settings: Settings,
|
||||
): DomSpan {
|
||||
|
Reference in New Issue
Block a user