You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
/** * Generates a blob to use for downloads or to generate a download URL. * Only supported in browsers supporting the Blob API. * * Unfortunately, because node.js has no Blob implementation (they have Buffer * instead), this method is currently untested. Sorry Dave… * * @since 1.9.0 */toBlob(): Blob;
When this .d.ts file is imported into a TypeScript project, the project fails to compile with this error message:
Error: node_modules\.pnpm\ical-generator@3.5.0-develop.1_6cpkm3xmcfrw36duhz3wk24ofa\node_modules
\ical-generator\dist\calendar.d.ts:402:15 - (TS2304) Cannot find name 'Blob'.
The reason is that the Blob API is not available in Node.js and thus is not defined by @types/node, as noted in the comments.
Workaround
The workaround is to set "skipLibCheck": true in tsconfig.json, which disables type checking for imported libraries. Some people recommend that practice, because less checking means tsc runs faster.
However it is obviously bad for professional projects: If the compiler reports an error for an imported .d.ts file, that means the compiler's analysis of those APIs is incorrect or incomplete. In other words, actual mistakes in your program may not get caught by the compiler, because it failed to compile your library typings correctly.
Therefore professional projects should ensure there are no such errors, which can only be accomplished by setting "skipLibCheck": false. Libraries should make sure that they can be successfully compiled in this mode.
Recommended fix
A simple solution would be to declare the API as toBlob(): any. A more sophisticated solution would be to declare a global type Blob = any which can get restricted by the real Blob API declaration when/if it is imported.
The text was updated successfully, but these errors were encountered:
I'm currently on vacation until mid-September and won't get to a fix before then. toBlob(): any seems a bit very hacky to me, but if someone could prepare a PR for the second proposal, I would look at it promptly.
I can't think of a solution off the top of my head that wouldn't be a breaking change for the toBlob() method, so I wouldn't pursue this issue further and instead refer to #478 which also fixes this issue. If there is a solution that would not be a breaking change, I would be very grateful for specific advice.
I just pushed a preview of ical-generator v6 to develop, which should fix this issue. I would be happy if you could test the new version and give me some feedback. You can install the version with npm i ical-generator@next. All changes in this release can be found here.
ical-generator/ical-generator/dist/calendar.d.ts
When this .d.ts file is imported into a TypeScript project, the project fails to compile with this error message:
The reason is that the
Blob
API is not available in Node.js and thus is not defined by@types/node
, as noted in the comments.Workaround
The workaround is to set
"skipLibCheck": true
in tsconfig.json, which disables type checking for imported libraries. Some people recommend that practice, because less checking meanstsc
runs faster.However it is obviously bad for professional projects: If the compiler reports an error for an imported .d.ts file, that means the compiler's analysis of those APIs is incorrect or incomplete. In other words, actual mistakes in your program may not get caught by the compiler, because it failed to compile your library typings correctly.
Therefore professional projects should ensure there are no such errors, which can only be accomplished by setting
"skipLibCheck": false
. Libraries should make sure that they can be successfully compiled in this mode.Recommended fix
A simple solution would be to declare the API as
toBlob(): any
. A more sophisticated solution would be to declare a globaltype Blob = any
which can get restricted by the real Blob API declaration when/if it is imported.The text was updated successfully, but these errors were encountered: