Skip to content
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

v2 custom tags: outdated doc and/or broken types #429

Closed
3bl3gamer opened this issue Dec 20, 2022 · 1 comment
Closed

v2 custom tags: outdated doc and/or broken types #429

3bl3gamer opened this issue Dec 20, 2022 · 1 comment
Labels
bug Something isn't working

Comments

@3bl3gamer
Copy link

Describe the bug
In the Writing Custom Tags there is an example:

  stringify(item, ctx, onComment, onChompKeep) {
    ...
    return stringifyString({ value: key }, ctx, onComment, onChompKeep)
  }

It worked in v1.10 but in v2.1 it returns type error:

Argument of type '{ value: string; }' is not assignable to parameter of type 'Scalar<unknown>'.
  Type '{ value: string; }' is missing the following properties from type 'Scalar<unknown>': toJSON, clone, [NODE_TYPE]

To Reproduce

Create custom tag with

  stringify(item, ctx, onComment, onChompKeep) {
    return stringifyString({ value: 'test' }, ctx, onComment, onChompKeep)
  }

Expected behaviour

No error.

Versions:

  • Environment: Node: 19.1.0
  • yaml: yaml: 2.1.3
@3bl3gamer 3bl3gamer added the bug Something isn't working label Dec 20, 2022
@eemeli eemeli closed this as completed in 97ec3e6 Dec 21, 2022
@eemeli
Copy link
Owner

eemeli commented Dec 21, 2022

Thank you for reporting this! The argument's type was indeed a bit too strict. This wasn't caught by the tests for custom types, as they are (still) JS rather than TS.

I've also made the examples in the docs a little bit more robust.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants