-
Notifications
You must be signed in to change notification settings - Fork 219
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[core] Improve documentation and implementation of Typekit, Mutator, and Realm #5149
base: main
Are you sure you want to change the base?
[core] Improve documentation and implementation of Typekit, Mutator, and Realm #5149
Conversation
All changed packages have been documented.
Show changes
|
/** | ||
* Mutate the type and recur, further mutating the type's children. This is the default behavior. | ||
*/ | ||
MutateAndRecur = 0, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I get that recur is the proper verb form... but recur is also kind of a general term for "might happen again" which is a bit ambiguous and recurse is I think commonly used as a verb, but maybe I'm some kind of heathen.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Personally I've always heard and said "recur" and never "recurse" (e.g. clojure's recur
operator) and didn't find a definition for "recurse" in the first dictionary I looked at (Merriam-Webster online), but I see now that many dictionaries do have a definition for it. In the context of formal functional programming, the relationship between a function and its recursive calls was always described to me as its "recurrence relation" and I think that "recursion" and "recurrence" are basically the same thing (after all, the reason it's called "recursion" is because you're defining a thing that recurs within its own definition.
I'm not married to the word "recur", so if you think "recurse" is better I wont object to reverting these back.
* causing parent navigation which in turn would mutate everything in that namespace. | ||
* Mutate the type graph, allowing namespaces to be mutated. | ||
* | ||
* **Warning**: This function will likely mutate the entire type graph. Most TypeSpec types relate to namespaces |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Might be good to add two things here: it will only mutate the entire type graph if you mutate namespaces, and if you don't want to mutate namespaces then you should use @ link mutateSubgraph.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It actually wont do that in its current implementation becuse mutateSubgraph does not follow namespace links. The implementation of child item following is pretty sparse.
If we have mutateSubgraph and mutateSubgraph with namespace traversal enabled, then it won't matter if you actually mutate a namespace, it will still follow namespace links in the visitor unless you visit those types and explicitly choose not to recur.
All this function actually does is allow you to pass a Namespace mutator at the type level. It doesn't do anything else differently. So the warning is optimistic for the future where we do have that behavioral difference.
I think at some point we will need to break mutateSubgraph out into an internal helper that allows you to say "yes I want to follow namespace links" or "no I dont want to follow namespace links".
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for taking the time to also do JSDocs, super helpful!
You can try these changes here
|
…-typekit-mutator-docs
realm
is a readonly property of the typekit.$
has been merged with a function that gets a typekit bound to a specific realm ($(realm)
) or bound to the default typekit realm of a specific program ($(program)
) making it easier to work in specific program contexts (e.g. ProjectedProgram). The default typekit bound to a realm is cached in the Realm itself.createTypekit
directly, bypassing the realm-caching behavior.MutableType
for accuracy. The previous definition was inaccurate and would fail to represent mutations of literal types correctly.