web-push
web-push copied to clipboard
Cannot read property 'generateRequestDetails' of undefined on TypeScript version greater than 4.0.
Got problem with web-push package using with typescript version greater than 4.0 but it works fine on typescript versions lesser than 4.0. Environment info:
- NodeJs Version: 14.17.6
- Yarn Version: 1.22.11
- web-push package version: 3.4.5
tsconfig.json:
{ "compilerOptions": { "outDir": "../out", "module": "commonjs", "target": "esnext", "moduleResolution": "node", "emitDecoratorMetadata": true, "experimentalDecorators": true, "sourceMap": true, "skipLibCheck": true, "declaration": false, "resolveJsonModule": true, "lib": [ "dom", "esnext", "esnext.asynciterable" ] }, "include": [ "./**/*" ] }
Error Message:
TypeError: Cannot read property 'generateRequestDetails' of undefined
I have the same issue.
I also encounter this error with Typescript 4.3.5
This library is exposing a singleton (instance object of a class), therefore it is not compatible with named import.
This doesn't work:
import { sendNotification } from 'web-push'
sendNotification(…)
But this works:
import * as webPush from 'web-push'
webPush.sendNotification(…)
We may include this importing guideline in the readme to help future users.
We may include this importing guideline in the readme to help future users.
Sounds good to me, PRs welcome ;) I'd also be OK with a PR to somehow make named import feasible.