type-graphql-dataloader
type-graphql-dataloader copied to clipboard
TypeORM types required
Hi, I am trying to use this library without the optional TypeORM support, but building the project fails:
node_modules/type-graphql-dataloader/dist/plugins/apollo-server/ApolloServerLoaderPlugin.d.ts:1:28 - error TS2307: Cannot find module 'typeorm' or its corresponding type declarations.
1 import { Connection } from "typeorm";
~~~~~~~~~
node_modules/type-graphql-dataloader/dist/decorators/typeorm/TypeormLoader.d.ts:1:28 - error TS2307: Cannot find module 'typeorm' or its corresponding type declarations.
1 import { ObjectType } from "typeorm";
~~~~~~~~~
Since I'm not using TypeORM, I don't want to add a dependency on it just to provide these types. I've worked around this by creating a typeorm.d.ts
file and manually stubbing those types:
declare module 'typeorm' {
type Connection = any;
type ObjectType<V> = any;
}
Ideally I wouldn't have to do this. This link has some possible solutions to solve this: https://stackoverflow.com/questions/54392809/how-do-i-handle-optional-peer-dependencies-when-publishing-a-typescript-package
Thank you for the issue. I confirmed that it produces errors as pointed out. I am contemplating what would be a good solution for this problem. The suggested link would help. Thank you!
I have changed to use import type
for typeorm's types so that the errors won't happen anymore. Please see if it works with the latest version of type-graphql-datloader
.
Hi, I've tested out the latest v0.3.7
release but unfortunately it appears to have the same issue.
I'm not familiar enough with this issue to have any better suggestions. Fixing it isn't critical to me, especially since there's a workaround, so don't worry if you can't find a solution.
@baumandm Thank you for trying it. Are you using TypeScript 3.8 or later? import type
won't be supported otherwise.
We faced the same issue on "type-graphql-dataloader": "^0.3.7"
. Typescript version is 4.0.3
Same issue on "type-graphql-dataloader": "^0.3.7". Typescript version is 3.8.3
Is it still the case at the latest version (v0.4.0
)?
Not using TypeORM either, so resolving this would help us out as well. Could still reproduce this with type-graphql-dataloader
version 0.5.0
, our TypeScript is "typescript": "^4.5.5"
.
lauriharpf@Lauris-MacBook-Pro projectdir % npx tsc
node_modules/type-graphql-dataloader/dist/decorators/typeorm/TypeormLoader.d.ts:1:33 - error TS2307: Cannot find module 'typeorm' or its corresponding type declarations.
1 import type { ObjectType } from "typeorm";
~~~~~~~~~
node_modules/type-graphql-dataloader/dist/plugins/apollo-server/ApolloServerLoaderPlugin.d.ts:2:33 - error TS2307: Cannot find module 'typeorm' or its corresponding type declarations.
2 import type { Connection } from "typeorm";
~~~~~~~~~
Found 2 errors.
Thank you for reporting.