• Jobs
  • About Us
  • Jobs
    • Home
    • Jobs
    • Courses and challenges
  • Businesses
    • Home
    • Post vacancy
    • Our process
    • Pricing
    • Assessments
    • Payroll
    • Blog
    • Sales
    • Salary Calculator

0

146
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?

over 3 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 Our process Sales
Legal
Terms and conditions Privacy policy
© 2025 PeakU Inc. All Rights Reserved.

Andres GPT

Show me some job opportunities
There's an error!