• Empleos
  • Sobre nosotros
  • profesionales
    • Inicio
    • Empleos
    • Cursos y retos
  • empresas
    • Inicio
    • Publicar vacante
    • Nuestro proceso
    • Precios
    • Evaluaciones
    • Nómina
    • Blog
    • Comercial
    • Calculadora de salario

0

129
Vistas
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?

almost 3 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Nuestro proceso Comercial
Legal
Términos y condiciones Política de privacidad
© 2025 PeakU Inc. All Rights Reserved.

Andres GPT

Recomiéndame algunas ofertas
Necesito ayuda