$ echo '<a id="foo">bat</a>' | tests/parse.js --html2wt <a id="foo">bat</a>
Unfortunately, that's not wikitext.
After https://gerrit.wikimedia.org/r/200914 is merged:
$ echo '<a id="foo"></a>' | tests/parse.js --html2wt [error/html2wt][enwiki/Main Page] Encountered <a id="foo"></a> -- serializing as extlink and dropping <a> attributes unsupported in wikitext. [ ]
...which is no better (some might say, worse).
We should probably just emit bat in this case (and log a warning).