Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

>1.1.2 doesn't compile in TypeScript projects with dom library disabled #40

Closed
shevchenkobn opened this issue Jun 28, 2024 · 4 comments · Fixed by #41
Closed

>1.1.2 doesn't compile in TypeScript projects with dom library disabled #40

shevchenkobn opened this issue Jun 28, 2024 · 4 comments · Fixed by #41
Assignees
Labels
bug Something isn't working

Comments

@shevchenkobn
Copy link

shevchenkobn commented Jun 28, 2024

Description

  1. Have a TypeScript project/codebase without dom type definitions (it can be done through setting tsc --lib es6 or similar).
  2. Install version after (not equal) 1.1.2 (including the latest - 1.5.1).
  3. Import anything from this package.
  4. Compile the project.

Compilation fails with the error:

node_modules/@pulsecron/pulse/dist/job/unique.d.ts:3:42 - error TS2304: Cannot find name 'Document'.

3 export type UniqueMethod<TSchema extends Document = Document> = (filter: Filter<TSchema>, options?: {
                                           ~~~~~~~~

node_modules/@pulsecron/pulse/dist/job/unique.d.ts:3:53 - error TS2304: Cannot find name 'Document'.

3 export type UniqueMethod<TSchema extends Document = Document> = (filter: Filter<TSchema>, options?: {

Code example

Compile this code

index.ts
// import {Document as MongoDocument} from 'mongodb';

// declare module '@pulsecron/pulse/dist/job/unique' {
//   type Document = MongoDocument;
// }

import {Processor} from '@pulsecron/pulse';

const p: Processor<any> = () => {};
package.json
{
  "name": "ts",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "build": "tsc --types node --lib es6 ./index.ts",
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "keywords": [],
  "author": "",
  "license": "ISC",
  "dependencies": {
    "@pulsecron/pulse": "^1.5.1"
  },
  "devDependencies": {
    "@types/node": "^20.14.9",
    "mongodb": "^6.8.0",
    "typescript": "^5.5.2"
  }
}

Additional context

Workaround

Add the declaration augmentation file (like src\@types\pulse-fixes.d.ts):

import {Document as MongoDocument} from 'mongodb';

declare module '@pulsecron/pulse/dist/job/unique' {
  type Document = MongoDocument;
}

Or simply uncomment the commented part of the Code example.

Fix

Import Document from mongodb in @pulsecron/pulse/src/job/unique 😀

import { Filter } from 'mongodb';

And disable DOM type definitions by lib in tsconfig.

@shevchenkobn shevchenkobn added the bug Something isn't working label Jun 28, 2024
@shevchenkobn shevchenkobn changed the title 1.1.3+ doesn't compile in TypeScript projects with dom library disabled >1.1.3 doesn't compile in TypeScript projects with dom library disabled Jun 28, 2024
@shevchenkobn shevchenkobn changed the title >1.1.3 doesn't compile in TypeScript projects with dom library disabled >1.1.2 doesn't compile in TypeScript projects with dom library disabled Jun 28, 2024
@code-xhyun
Copy link
Contributor

@shevchenkobn I will solve these and give you an answer as soon as possible.

@code-xhyun code-xhyun linked a pull request Jun 29, 2024 that will close this issue
@code-xhyun
Copy link
Contributor

code-xhyun commented Jun 29, 2024

🎉 This Issue is included in version 1.5.2 🎉

The release is available on:

npm package (@latest dist-tag)
GitHub release

@shevchenkobn
Copy link
Author

🎉 This Issue is included in version 1.5.2 🎉

The release is available on:

npm package (@latest dist-tag) GitHub release

Wow, thank you! You did it blazingly fast! Even I took much longer to respond 😄
I have never seen such a fast open-source issue processing!

@code-xhyun
Copy link
Contributor

🎉 This Issue is included in version 1.5.2 🎉

The release is available on:

npm package (@latest dist-tag) GitHub release

Wow, thank you! You did it blazingly fast! Even I took much longer to respond 😄

I have never seen such a fast open-source issue processing!

@shevchenkobn I've solved this, but please check if your problem has been solved as well

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants