-
-
Notifications
You must be signed in to change notification settings - Fork 106
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
Generic argument support for node methods #383
Generic argument support for node methods #383
Conversation
@golergka I'd like to expand this PR a bit to package in a few more TS changes, including a port of |
Certainly! It's your repo, after all 😁 |
/** Utility type mapper */ | ||
export type NodeType<T> = T extends string | number | bigint | boolean | null | ||
? Scalar<T> | ||
: T extends Array<any> | ||
? YAMLSeq<NodeType<T[number]>> | ||
: T extends { [key: string | number]: any } | ||
? YAMLMap<NodeType<keyof T>, NodeType<T[keyof T]>> | ||
: Node |
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.
This isn't currently publicly exported, but I wonder if it'd be useful outside of createNode()
? Also happy to bikeshed on the name.
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.
c2254de
to
c0db02a
Compare
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 think this is getting good. A few nitpicky fixes, and then we can merge this.
Thank you @golergka! Very happy to have this included. I've a couple of other minor things that I want to get in, but then should be able to get a new release out within a week or so. |
Closes #382
I'd like to add some tests that use types as well, but the relevant test
collection-access.js
is currently untyped, and changing it seemed a little to large a change for a first contribution.