node-file-dialog icon indicating copy to clipboard operation
node-file-dialog copied to clipboard

Error: Missing declaration file

Open RaulCatalinas opened this issue 1 year ago • 0 comments

I've encountered an error when trying to use node-file-dialog in my TypeScript project.

The error message is:

Could not find a declaration file for module 'node-file-dialog'. 'c:/Users/raulc/Desktop/Dev/Webs/EasyViewerWeb/node_modules/node-file-dialog/index.js' implicitly has an 'any' type.

Steps to Reproduce:

  1. Install node-file-dialog
npm install node-file-dialog
  1. Import the module in your code
import dialog from 'node-file-dialog'

const [directory] = await dialog({ type: 'directory' })

console.log({ directory })
  1. Attempt to use the functionality provided by node-file-dialog

Expected Behavior:

The TypeScript compiler should be able to find a declaration file (.d.ts) for the node-file-dialog module, providing type information for its functions and variables. This allows for type safety and better code completion.

Actual Behavior:

The TypeScript compiler cannot locate a declaration file, resulting in the error message and assigning the any type to the module, which reduces type safety and may lead to potential runtime errors.

Additional Information:

TypeScript version: 5.4.5 Node.js version: 20.11.1 node-file-dialog version: 1.0.3

RaulCatalinas avatar Apr 19 '24 12:04 RaulCatalinas