Skip to content

[Typings imporve] format option should be required #223

@fider

Description

@fider

Hi, nice lib.

In my opinion OptionsForHtmlFileAsValidationTargetAndObjectAsResult and OptionsForExternalUrlAsValidationTargetAndObjectAsResult should mark format as required, even if it contains only single value, because typings are not fulfilled in below case:

// JSON options
const options:
      | htmlValidator.OptionsForHtmlFileAsValidationTargetAndObjectAsResult
      | htmlValidator.OptionsForExternalUrlAsValidationTargetAndObjectAsResult
  = {
    data: args.html,
    isFragment: true
  };

// JSON response
let result: htmlValidator.ParsedJsonAsValidationResults;

try{
  result = await htmlValidator(options);
  ...
result.messages.length

In above case I expect result to be JSON, instead string is returned until format: 'json' is provided explicitly. This causes runtime error but should be detected during compilation.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions