Open andreialecu opened 4 years ago
Related: #6
Is there a workaround for this? I'm stuck using esModuleInterap
to support other modules.
Casting generateDataLoader(): any
squashes the typescript error, but results in the loader failing to properly load.
Nest could not find MyLoader element (this provider does not exist in the current context)
I personally used https://www.npmjs.com/package/patch-package to replace this line:
https://github.com/krislefeber/nestjs-dataloader/blob/df8fa93897389ee692e9137c6beb7629f81d86c3/index.ts#L11
with import DataLoader from 'dataloader';
Currently this package distributes the index.ts
source file, which is what TypeScript picks up for the package's type definitions. I think this issue might be fixed by switching to distributing a generated index.d.ts
definition file instead.
The project I'm trying to use
nestjs-dataloader
in usesimport DataLoader from "dataloader";
syntax for imports, via theesModuleInterop: true
flag in tsconfig.jsonThis seems to conflict with the way
DataLoader
is imported here: https://github.com/krislefeber/nestjs-dataloader/blob/master/index.ts#L11And it results in errors such as:
I have confirmed that changing the
tsconfig
ofnestjs-dataloader
to enableesModuleInterop
and using the same of type of import results in the error being fixed.I'm not sure what the proper fix is here, but I think as a best practice, the typescript file should not be published to npm, but instead only publish the
d.ts
and compiled.js
. It's likely that theindex.ts
file is interfering somehow.