-
Notifications
You must be signed in to change notification settings - Fork 103
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
Export types with export type
#1284
Conversation
This is a problem with the build system, since type export/import statements are optional. What is the error? |
The problem is that we strongly prefer to consume the source code (better go-to-definition, faster builds for us), not the compiled code. Webpack then complains about it not being to find the things being exported here, as they refer to types. What would be the downside of having these exported as types instead of normal exports? |
You generate the client source code and merge it into a larger compiled application? That's fine. I'll let the team know to review this PR and we will likely merge it, but the real fix is going to be in your webpack configuration. You can also configure a post-generation step. You may have a linting/formatting transform applied after code generation, and in that you can add https://typescript-eslint.io/rules/consistent-type-exports/ or https://biomejs.dev/linter/rules/use-export-type/. |
writer.write("export type { __MetadataBearer };"); | ||
writer.write("export { $$Command };"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think they can both be exported as types, this was mainly for documentation improvements, e.g. https://github.com/aws/aws-sdk-js-v3/blob/8fa2ae41e6e9d3e5c23c38bcd44dad03f395bb74/clients/client-kendra-ranking/src/commands/CreateRescoreExecutionPlanCommand.ts#L12-L15
writer.write("export type { RuntimeExtension } from \"./runtimeExtensions\";"); | ||
writer.write("export type { $LExtensionConfiguration } from \"./extensionConfiguration\";", normalizedClientName); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Exporting these as types will have no problem since they are both interfaces, e.g.
RuntimeExtension
: https://github.com/aws/aws-sdk-js-v3/blob/8fa2ae41e6e9d3e5c23c38bcd44dad03f395bb74/clients/client-kendra-ranking/src/runtimeExtensions.ts#L12-L17*ExtensionConfiguration
: https://github.com/aws/aws-sdk-js-v3/blob/8fa2ae41e6e9d3e5c23c38bcd44dad03f395bb74/clients/client-kendra-ranking/src/extensionConfiguration.ts#L8-L15
@libre-man It looks like the Java checkstyle is failing, can you resolve the errors? |
|
Done @syall! |
Anything I need to do get this merged still? |
Description of changes: Some types were exported with
export
instead ofexport type
which is causing issues in our build system. This indicates more clearly that a type is exported, and no runtime behaviour is changed.