-
-
Notifications
You must be signed in to change notification settings - Fork 112
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
types: revist transformer typescript interface #65
Labels
Comments
This was referenced Jul 20, 2019
After trying out |
ChristianMurphy
added a commit
to syntax-tree/unist-util-visit
that referenced
this issue
Jul 31, 2019
related to: unifiedjs/unified#65 related to: syntax-tree/unist-util-visit-parents#7 resolves #15 * types: add typings and type tests for unist-util-visit * types: drop unused generic * test: add test for array of tests passed to visit * style: format type config files * types: leverage unist-util-is helpers * test: refactor examples to handle unknown type for node param * build: update dependency on unist-util-is to version 4 * types: leverage helper types from unist util visit parents, add actions * build: leverage stable unist-util-visit-parents 3.0.0 release
wooorm
pushed a commit
to syntax-tree/unist-util-visit
that referenced
this issue
Jul 31, 2019
Related-to: unifiedjs/unified#65. Related-to: syntax-tree/unist-util-visit-parents#7. Closes GH-15. Reviewed-by: Junyoung Choi <[email protected]> Reviewed-by: Titus Wormer <[email protected]>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
Subject of the feature
Update the
Transformer
interface to better reflect the types being passed in.Problem
Transformer expects to receive exactly a unist
Node
unified/types/index.d.ts
Lines 296 to 316 in e408747
When in most cases parsers will return a
RootNode
which extendsParentNode
which adds an extrachildren
attribute thatNode
does not expect.remark
ran into a similar issue to this with thevisitor
interface, see remarkjs/remark#426Expected behaviour
Ideally avoid requiring
as
casting thenode
parameter.Alternatives
<T extends Node>
to guarantee the incoming node is a super type ofNode
, though it may or may not reflect the correct super type.Processor
to accept a generic of all possible types (E.G. allmdast
nodes) and pass that generic type union in (Open question: How would plugins add new types to the union?)The text was updated successfully, but these errors were encountered: