html-validator
html-validator copied to clipboard
[Typings imporve] format option should be required
trafficstars
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.