apollo-tooling
apollo-tooling copied to clipboard
Add typescript support for apollo.config.ts
Creating a new config with the proper fields is quite burdensome, since the fields allowed are non-obvious and error messaging could be improved. Adding typescript to the apollo config would provide editor completion and an understanding of the acceptable fields/values.
This issue is a feature request for a technical solution, so there may be a better way to accomplish this task, such as a linter
This kinda works but is broken. If one gives apollo.config.ts file with --config option it seems to pick it up but can't really compile. For me causes
Export assignment cannot be used when targeting ECMAScript modules. Consider using 'export default' or another module format instead.
So export = {config} don't work. But neither does export defaults:
The error was: TypeScriptCompileError: Failed to compile TypeScript: Unexpected token 'export'
This kinda works but is broken. If one gives apollo.config.ts file with --config option it seems to pick it up but can't really compile. For me causes
Export assignment cannot be used when targeting ECMAScript modules. Consider using 'export default' or another module format instead.
So export = {config} don't work. But neither does export defaults:
The error was: TypeScriptCompileError: Failed to compile TypeScript: Unexpected token 'export'
If you are able to use module: commonjs
in project tsconfig it actually works. However I'm not so had to use js file as a config.
This could actually be somewhat solved if there is a TS file that exports the schema for the config file. All we need to do is use a JSDoc comment above the config, and it'll apply the type:
/**
* @type {import('from-here').Type}
*/
Actualization this issue with my message. Any plans or updates?