I am writing Thunderbird WebExtension. I want to use Parsimmon in it. But when importing the module, Thunderbird claims
Uncaught Error: Dynamic require of "parsimmon" is not supported
(This message is printed if require === undefined
)
So I decided to load umd.min.js via <script>
tag in backgorund.html
and options.html
. But I don't know how to use type definition.
My current workaround is writing declare global {}
and copy-and-pasting part of parsimmon.d.ts
into it.
export {}
declare global {
namespace Parsimmon {
// ...
}
}
VSCode code completion works well with this declaration.
import P = Parsimmon;
const integer: P.Parser<number> = P.regexp(/[0]|[1-9][0-9]*/).map(parseInt);
But I want to avoid copy-and-paste. Is there anyway to make use of node_modules/@types/parsimmon/index.d.ts
directly?