Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

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

about 4 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 Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda