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

Final Typescript Support #343

Closed
Tjerk-Haaye-Henricus opened this issue Oct 24, 2022 · 5 comments
Closed

Final Typescript Support #343

Tjerk-Haaye-Henricus opened this issue Oct 24, 2022 · 5 comments

Comments

@Tjerk-Haaye-Henricus
Copy link

Tjerk-Haaye-Henricus commented Oct 24, 2022

Hey There, first of all I'm really thankful for this library.

I'm using it since a long time now. Since the world seems to switch to esm i would do so too. But unfortunately since this moment this library does not work anymore.

I'm using it along with type-graphql so i really really need types without that i'm not able to upload files.
Of course I've already added an issue over there to make sure i will find a solution.

Nevertheless...

While importing the files
image

Could not find a declaration file for module 'graphql-upload/Upload.mjs'. 'node_modules/graphql-upload/Upload.mjs' implicitly has an 'any' type.

This is my tsconfig.json

{
  "compilerOptions": {
    "allowJs": true,
    "baseUrl": ".",
    "declaration": true,
    "declarationMap": true,
    "esModuleInterop": true,
    "experimentalDecorators": true,
    "lib": ["es2018", "esnext.asynciterable"],
    "module": "esnext",
    "moduleResolution": "nodenext",
    "outDir": "build",
    "removeComments": true,
    "resolveJsonModule": true,
    "skipLibCheck": true,
    "sourceMap": true,
    "strict": true,
    "target": "es2018"
  },
  "include": ["source"],
  "exclude": ["build"]
}

Maybe I'm doing something wrong but i really don't know what.

I read along alot of issues about this topic and it seems that a lot of people feel with me. For me this is a really hard situation because without types in such a central part of my application it feels like no good deal to me using this library. It's not possible to me, to change my typescript configuration to commonjs to make a single library work.

I can really understand that maintaining a library as famous as this one is a real hard thing. And i'm really thankful that you've spend so much time creating this library.

While reading i did not really get the point of not using typescript here. Wouldnt it be much easier to do it in Typescript since there are so much people out there using it?

So i have at least two Questions.

Will there ever be proper types for this package ?
If not is there a package which you might know solving my problems uploading Files with proper typings.

@Tjerk-Haaye-Henricus
Copy link
Author

btw: Here the link to type-graphql MichalLytek/type-graphql#1372

@jaydenseric
Copy link
Owner

While reading i did not really get the point of not using typescript here.

This project has 100% type safety, checked with TypeScript:

"types": "tsc -p jsconfig.json",

Having types held in the actual module that is being used is superior to having definition files seperate to the module, for reasons that have been explained in detail in various other issues and PR's. For example, Deno users can import those modules via HTTP imports from a CDN that statically hosts the package. For everyone, it's super nice being able to CMD+Click on code and make your way to the source module and see the real source code instead of going to some seperate definition file.

Some suggestions to try to fix your TS config:

  • Change compilerOptions.module to "nodenext".
  • Add compilerOptions.maxNodeModuleJsDepth with a value of something like 10.

Maybe try TS compiling a module that imports from graphql-upload, then look at the resulting .js or .mjs file that's emitted and see if the import it's creating makes sense; you could even try running it with Node.js to check if Node.js is able to resolve the import ok.

@Tjerk-Haaye-Henricus
Copy link
Author

Thanks 1000 Times for the quick reply :)

Ahh so it's maybe on my side to add some knowledge in that particular topic too :) I would like to move to bun when it becomes usable in production maybe i need to go that direction there too :)

I know that this is definitively a way to much questions but do you have an idea why type-graphql cannot infer graphql types from that library anymore ? In the old package apollo-upload-server it was possible. I've added a issue on type-graphql aswell MichalLytek/type-graphql#1372

Maybe you know how to deal with that :)

thanks so far already 🙏 🙏 🙏

@jaydenseric
Copy link
Owner

You're welcome :)

do you have an idea why type-graphql cannot infer graphql types from that library anymore ?

I'm not the best person to ask; I don't use or maintain type-graphql.

Closing because there doesn't appear to be anything to action here in this repo; if something comes up during the investigation in MichalLytek/type-graphql#1372 that should be actioned here we can reopen.

@jaydenseric jaydenseric closed this as not planned Won't fix, can't repro, duplicate, stale Oct 24, 2022
@Tjerk-Haaye-Henricus
Copy link
Author

Yes i will keep you updated in case someone is using type-graphql as i do :)
Thanks again for the support 🙏

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

2 participants