Open stefreak opened 1 year ago
That's a fair concern. A method for discovering unresolved aliases should be provided, and a parsing option to include errors for them.
Pondering now whether something actually needs to be added, as this works, and provides an opportunity to take whatever locally appropriate action when encountering an unresolvable alias.
import { parseDocument, visit } from 'yaml'
const doc = parseDocument('foo: *bar');
visit(doc, {
Alias(key, node) {
if (!node.resolve(doc)) throw new Error(`Unresolved alias: ${node}`)
}
});
Describe the bug When parsing a document like this:
The
errors
array on the parsed document is empty, andtoJS
will throwReferenceError: Unresolved alias
To Reproduce
Expected behaviour I expect an error on the document after calling
yaml.parseAllDocuments
.Versions (please complete the following information):
yaml
: 2.3.2