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

TypeORM types required #10

Open
baumandm opened this issue Nov 12, 2020 · 9 comments
Open

TypeORM types required #10

baumandm opened this issue Nov 12, 2020 · 9 comments
Labels
bug Something isn't working help wanted Extra attention is needed

Comments

@baumandm
Copy link

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

@slaypni
Copy link
Owner

slaypni commented Nov 13, 2020

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!

@slaypni
Copy link
Owner

slaypni commented Nov 15, 2020

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.

@baumandm
Copy link
Author

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.

@slaypni
Copy link
Owner

slaypni commented Nov 23, 2020

@baumandm Thank you for trying it. Are you using TypeScript 3.8 or later? import type won't be supported otherwise.

@vhatsura
Copy link

We faced the same issue on "type-graphql-dataloader": "^0.3.7". Typescript version is 4.0.3

@slaypni slaypni added bug Something isn't working help wanted Extra attention is needed labels Jan 12, 2021
@nudabagana
Copy link

Same issue on "type-graphql-dataloader": "^0.3.7". Typescript version is 3.8.3

@slaypni
Copy link
Owner

slaypni commented Jun 4, 2021

Is it still the case at the latest version (v0.4.0)?

@lauriharpf
Copy link

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.

@slaypni
Copy link
Owner

slaypni commented Feb 20, 2022

Thank you for reporting.

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

No branches or pull requests

5 participants