Support Deno-compatible TypeScript outputs
Is your feature request related to a problem? Please describe.
Currently, it's not possible to consume TypeScript outputs from graphql-codegen in Deno, as the imports are either extensionless or use .js extensions(with emitLegacyCommonJSImports: false), whereas it must be .ts in Deno.
Describe the solution you'd like
Not sure, especially since we already have emitLegacyCommonJSImports config, which affects the import extensions. Maybe we should deprecate the existing config and then replace it with something more configurable.
Describe alternatives you've considered
No response
Any additional important details?
Here's the relevant codegen config (and a hacky workaround)
Thank you for the example hook. I've implemented the following into my config so that my generated gql.ts file imports from .ts rather than .js:
const config: CodegenConfig = {
// ...
hooks: {
beforeOneFileWrite: (_, content: string) => content.replace(/\.js/g, '.ts')
},
}
There is a disgusting hack that works:
"baseTypesPath": "types/schema.mts.mts"
Use .mts.mts and the last .mts will be automatically stripped, leaving behind the second one for a correct fully specified import path including the file extension.