Skip to content

Commit 3798bc1

Browse files
authored
Export types with export type (#1284)
* Export types with `export type` * Fix linter error * Also export ServiceExceptionOptions as type
1 parent 05b2fb2 commit 3798bc1

File tree

3 files changed

+9
-4
lines changed

3 files changed

+9
-4
lines changed

smithy-typescript-codegen/src/main/java/software/amazon/smithy/typescript/codegen/CommandGenerator.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -384,7 +384,8 @@ private void generateCommandMiddlewareResolver(String configType) {
384384

385385
private void addInputAndOutputTypes() {
386386
writer.writeDocs("@public");
387-
writer.write("export { __MetadataBearer, $$Command };");
387+
writer.write("export type { __MetadataBearer };");
388+
writer.write("export { $$Command };");
388389

389390
writeInputType(inputType.getName(), operationIndex.getInput(operation), symbol.getName());
390391
writeOutputType(outputType.getName(), operationIndex.getOutput(operation), symbol.getName());

smithy-typescript-codegen/src/main/java/software/amazon/smithy/typescript/codegen/IndexGenerator.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,8 +114,11 @@ private static void writeClientExports(
114114
}
115115

116116
// Export Runtime Extension and Client ExtensionConfiguration interfaces
117-
writer.write("export { RuntimeExtension } from \"./runtimeExtensions\";");
118-
writer.write("export { $LExtensionConfiguration } from \"./extensionConfiguration\";", normalizedClientName);
117+
writer.write("export type { RuntimeExtension } from \"./runtimeExtensions\";");
118+
writer.write(
119+
"export type { $LExtensionConfiguration } from \"./extensionConfiguration\";",
120+
normalizedClientName
121+
);
119122

120123
// Write export statement for commands.
121124
writer.write("export * from \"./commands\";");

smithy-typescript-codegen/src/main/java/software/amazon/smithy/typescript/codegen/integration/AddBaseServiceExceptionClass.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,8 @@ private void writeAdditionalFiles(
6969
TypeScriptDependency.AWS_SMITHY_CLIENT);
7070
// Export ServiceException information to allow
7171
// documentation inheritance to consume their types
72-
writer.write("export { __ServiceException, __ServiceExceptionOptions }\n");
72+
writer.write("export type { __ServiceExceptionOptions }\n");
73+
writer.write("export { __ServiceException }\n");
7374
writer.writeDocs("@public\n\nBase exception class for all service exceptions from "
7475
+ serviceName + " service.");
7576
writer.openBlock("export class $L extends __ServiceException {", serviceExceptionName);

0 commit comments

Comments
 (0)