Skip to content

Commit 20cc42f

Browse files
committed
Fix import issue to only import when needed
1 parent 6b9cf83 commit 20cc42f

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,12 @@
4343
final class TypeScriptWriter extends CodeWriter {
4444

4545
private final Path moduleName;
46+
private final String moduleNameString;
4647
private final ImportDeclarations imports;
4748

4849
TypeScriptWriter(String moduleName) {
4950
this.moduleName = Paths.get(moduleName);
51+
moduleNameString = moduleName;
5052
imports = new ImportDeclarations(moduleName);
5153

5254
setIndentText(" ");
@@ -63,7 +65,9 @@ final class TypeScriptWriter extends CodeWriter {
6365
*/
6466
TypeScriptWriter addImport(Symbol symbol) {
6567
if (!symbol.getNamespace().isEmpty()) {
66-
addImport(symbol.getName(), symbol.getName(), symbol.getNamespace());
68+
if (!symbol.getNamespace().equals(moduleNameString)) {
69+
addImport(symbol.getName(), symbol.getName(), symbol.getNamespace());
70+
}
6771
for (SymbolReference reference : symbol.getReferences()) {
6872
addImport(reference);
6973
}

0 commit comments

Comments
 (0)