Vonage / vonage-node-sdk

Vonage API client for Node.js. API support for SMS, Voice, Text-to-Speech, Numbers, Verify (2FA) and more.
Apache License 2.0
375 stars 178 forks source link

[Bug]: typescript results in vetch missing @types/node-fetch #901

Closed lawrenceong closed 5 months ago

lawrenceong commented 5 months ago

Node Version

20.x

Platform

Mac (Apple Silcon)

SDK Version

3.12.0

Code Sample

Using typescript:

package.json

{
  "name": "test-vonage",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "author": "",
  "license": "ISC",
  "dependencies": {
    "@vonage/server-sdk": "^3.12.0"
  },
  "devDependencies": {
    "typescript": "^5.3.3"
  }
}

tsconfig.json

{
  "compilerOptions": {
    "module": "nodenext",
    "noImplicitAny": true,
    "removeComments": true,
    "preserveConstEnums": true,
    "sourceMap": true,
    "moduleResolution": "nodenext"
  },
  "include": ["src/**/*.ts"]
}

src/index.ts

import { Vonage } from '@vonage/server-sdk';

Expected Behavior

Code works without any issue when running tsc

Actual Behavior

Results in an error attempting to compile it using npx tsc

npm i
npx tsc
node_modules/@vonage/server-client/dist/client.d.ts:1:26 - error TS7016: Could not find a declaration file for module 'node-fetch'. '.../node_modules/node-fetch/lib/index.js' implicitly has an 'any' type.
  Try `npm i --save-dev @types/node-fetch` if it exists or add a new declaration (.d.ts) file containing `declare module 'node-fetch';`

1 import { Response } from 'node-fetch';
                           ~~~~~~~~~~~~

node_modules/@vonage/vetch/dist/errors/vetchError.d.ts:2:26 - error TS7016: Could not find a declaration file for module 'node-fetch'. '.../node_modules/node-fetch/lib/index.js' implicitly has an 'any' type.
  Try `npm i --save-dev @types/node-fetch` if it exists or add a new declaration (.d.ts) file containing `declare module 'node-fetch';`

2 import { Response } from 'node-fetch';
                           ~~~~~~~~~~~~

Found 2 errors in 2 files.

Errors  Files
     1  node_modules/@vonage/server-client/dist/client.d.ts:1
     1  node_modules/@vonage/vetch/dist/errors/vetchError.d.ts:2
manchuck commented 5 months ago

Apologies, I have added that type definition to v3.12.1 for @vonage/server-sdk (v1.7.1 for @vonage/vetch and v1.10.1 for @vonage/server-client)