I have recently created a file named global.d.ts within the src folder and it contains the following content:
declare module 'ol-contextmenu';
Despite my efforts, placing the file in the root directory or in node-modules/@types did not solve the issue.
In my component, I import ol-contextmenu (which lacks types) like so:
import ContextMenu from 'ol-contextmenu';
I have made various edits to tsconfig.json in an attempt to locate the .d.ts file. For example:
"include": [
"src/global.d.ts"
]
However, I consistently encounter this error:
error TS7016: Could not find a declaration file for module 'ol-contextmenu'. 'C:/dev/nis/NIS/ClientApp/node_modules/ol-contextmenu/dist/ol-contextmenu.js' implicitly has an 'any' type. Try
if it exists or add a new declaration (.d.ts) file containingnpm install @types/ol-contextmenu
declare module 'ol-contextmenu';
5 import ContextMenu from 'ol-contextmenu'; ~~~~~~~~~~~~~~~~
Even attempting to copy the file to node-modules/@types yields the same error message.