You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently the types for the custom generator looks like this
/** * Code generator for each node type. */exporttypeGenerator={[TinEstreeNode['type']]: (node: EstreeNode&{type: T},state: State,)=>void}/** * Code generator options. */exportinterfaceOptions<Output=null>{/** * If present, source mappings will be written to the generator. */sourceMap?: SourceMapGenerator/** * String to use for indentation, defaults to `"␣␣"`. */indent?: string/** * String to use for line endings, defaults to `"\n"`. */lineEnd?: string/** * Indent level to start from, defaults to `0`. */startingIndentLevel?: number/** * Generate comments if `true`, defaults to `false`. */comments?: boolean/** * Output stream to write the render code to, defaults to `null`. */output?: Output/** * Custom code generator logic. */generator?: Generator}
which is fine but this means we have no way of parsing an actual custom tree without ignoring errors. What i propose is to change the signature of the generate function to allow the user to pass a generic that specifies the shape of it's own ast.
Thanks @paoloricciuti for mentioning this. The types could indeed be enhanced by making the Options type generic with inferred arguments (this means that Output should extend the necessary stream interface if defined).
Thanks @paoloricciuti for mentioning this. The types could indeed be enhanced by making the Options type generic with inferred arguments (this means that Output should extend the necessary stream interface if defined).
Motivation
Currently the types for the custom generator looks like this
which is fine but this means we have no way of parsing an actual custom tree without ignoring errors. What i propose is to change the signature of the generate function to allow the user to pass a generic that specifies the shape of it's own ast.
Something like this
Expected behavior
I would love to specify extra nodes of my Ast without incurring in ts errors.
The text was updated successfully, but these errors were encountered: