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

Should return addTransactionalDataSource as promise #16

Closed
TouchSek opened this issue Oct 17, 2022 · 4 comments
Closed

Should return addTransactionalDataSource as promise #16

TouchSek opened this issue Oct 17, 2022 · 4 comments

Comments

@TouchSek
Copy link

The problem is when we are using it with Nestjs, and using dataSourceFactory, it will resolve the wrong return type. since the dataSourceFactory need to return as Promise<DataSource>

For a temporary solution I have to do like:

dataSourceFactory: (options) => {
  if (!options) {
    throw new Error('Invalid options passed')
  }

  return addTransactionalDataSource(new DataSource(options)) as unknown as Promise<DataSource>
},
@neoatlan
Copy link

Please put async keyword to the arrow function

@chantouchsek
Copy link

But async alone is not working and I don't want to disable the eslint for that kind.

@neoatlan
Copy link

I think your project has a rule that forbids the async keyword on functions that only have synchronous operations.
How about this way?
return Promise.resolve(addTransactionalDataSource(...))

@TouchSek
Copy link
Author

Thanks, man it's working.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants