types: update scope type annotations to use ScopeType for better type…#3490
Merged
Conversation
josdejong
added a commit
that referenced
this pull request
Jun 11, 2025
… `custom_scope_objects.js` and an internal tool (see #3490)
josdejong
requested changes
Jun 11, 2025
Owner
josdejong
left a comment
There was a problem hiding this comment.
Thanks a lot @JayChang4w , this is a neat improvement!
I made three inline comments, can you have a look at those?
…return type - Renamed ScopeType to MathScope for naming consistency in type definitions. - Changed the return type of MapLike interface methods for clarity.
…ion as evaluation scope.
josdejong
approved these changes
Jun 11, 2025
Owner
josdejong
left a comment
There was a problem hiding this comment.
Thanks for the updates Jay, looks good 👌 .
Owner
|
This fix is published now in |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Hi 👋
This PR improves the
ScopeTypedefinition by allowing custom Map-like objects, as shown in the example.Changes
MapLikeinterface for duck-typed scope objects withget,set,has, andkeysmethods.ScopeTypeto support either a plain object or aMapLikeobject.Why
While reviewing the documentation, I noticed that
math.evaluate()supports custom scope objects with map-like behavior. However, the current type definition usesany, which loses type safety in TypeScript.This change reflects the intended usage from the docs and makes TypeScript support more accurate.
Let me know if there's anything I should adjust. Thanks!