Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

182
Views
Is it possible to use type definition without import?

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?

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!