mirror of
https://github.com/Smaug123/KaTeX
synced 2025-10-05 11:18: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
@@ -15,8 +15,8 @@ class ParseError {
|
||||
// Error position based on passed-in Token or ParseNode.
|
||||
|
||||
constructor(
|
||||
message: string, // The error message
|
||||
token?: Token | ParseNode, // An object providing position information
|
||||
message: string, // The error message
|
||||
token?: Token | ParseNode<*>, // An object providing position information
|
||||
) {
|
||||
let error = "KaTeX parse error: " + message;
|
||||
let start;
|
||||
|
Reference in New Issue
Block a user