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