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

[bug] yaml types -- ignores schema #679

Closed
brandonkal opened this issue Jan 21, 2020 · 1 comment · Fixed by #1048
Closed

[bug] yaml types -- ignores schema #679

brandonkal opened this issue Jan 21, 2020 · 1 comment · Fixed by #1048

Comments

@brandonkal
Copy link
Contributor

https://github.com/denoland/deno/blob/9de8178c9b9bc21cc880ea81f163118408cc6c46/std/encoding/yaml/parse.ts#L28

Following the types for yaml.parseAll(), the caller expects this to function:

yaml.parseAll(result, undefined, { schema: yaml.JSON_SCHEMA })

However, parseAll types hide what is really going on:

export function loadAll<T extends CbFunction | LoaderStateOptions>(
  input: string,
  iteratorOrOption?: T,
  options?: LoaderStateOptions
): T extends CbFunction ? void : unknown[] {
  if (!isCbFunction(iteratorOrOption)) {
    return loadDocuments(input, iteratorOrOption as LoaderStateOptions) as Any;

undefined is not a callback function and so the third parameter is ignored.

The way to call it is like so, which the types do not allow:

//@ts-ignore -- this is a bug in YAML library
yaml.parseAll(result, { schema: yaml.JSON_SCHEMA })
@stale
Copy link

stale bot commented Jan 6, 2021

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant