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

226
Vistas
How to get ng-packagr to recognize a Typescript type definition

Since upgrading to Typescript 4.4.2 (needed to support Angular 13), the require syntax is no longer supported.

Now it seems I must use this syntax instead:

import * as d3ContextMenu from 'd3-context-menu';

Type definitions don't exist for d3-context-menu in DefinitelyTyped or anywhere else that I could find. So, I've tried creating my own using these instructions: (see "Plan C" here)

The problem is when I try to use these type definitions in a project compiled using ng-packagr I can't get it to work.(it works in a regular Angular project)

What am I missing here? What's the secret sauce to including this type definition file?

Files used in an unsuccessful attempt to import the custom type definition

enter image description here

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

When you build an Angular library using ng-packgr it does not bundle the dependencies into the library bundle. Instead what we usually do is adding the dependency needed by the library to the peerDependencies of the library and then to the App's dependencies. That means that even if you add the declaration for d3-context-menu to your library TS won't be able to find it automagically and you need to specify the declaration file for d3-context-menu at the application level.

about 4 years ago · Juan Pablo Isaza Denunciar
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