From 3210cc9e023c71e6d744926b11a8fd3b3e749cd1 Mon Sep 17 00:00:00 2001 From: mmews Date: Tue, 23 Jan 2024 09:18:55 +0100 Subject: [PATCH] respect bare imports --- .../n4js/transpiler/dts/print/PrettyPrinterDts.java | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/plugins/org.eclipse.n4js.transpiler.dts/src/org/eclipse/n4js/transpiler/dts/print/PrettyPrinterDts.java b/plugins/org.eclipse.n4js.transpiler.dts/src/org/eclipse/n4js/transpiler/dts/print/PrettyPrinterDts.java index a98e46467b..2bc5c6a22d 100644 --- a/plugins/org.eclipse.n4js.transpiler.dts/src/org/eclipse/n4js/transpiler/dts/print/PrettyPrinterDts.java +++ b/plugins/org.eclipse.n4js.transpiler.dts/src/org/eclipse/n4js/transpiler/dts/print/PrettyPrinterDts.java @@ -218,11 +218,17 @@ public Boolean caseImportDeclaration(ImportDeclaration original) { if (original.getModuleSpecifierForm() != ModuleSpecifierForm.PROJECT && Strings.isNullOrEmpty(URIUtils.fileExtension(URIUtils.toFileUri(moduleSpecifier)))) { - moduleSpecifier += "." + N4JSGlobals.DTS_FILE_EXTENSION; + + String extension = original.isBare() ? N4JSGlobals.JS_FILE_EXTENSION : N4JSGlobals.DTS_FILE_EXTENSION; + moduleSpecifier += "." + extension; } processAnnotations(original.getAnnotations()); - write("import type "); + write("import "); + if (!original.isBare()) { + write("type "); + } + // 1) import specifiers List importSpecifiers = new ArrayList<>(original.getImportSpecifiers()); if (!importSpecifiers.isEmpty() && importSpecifiers.get(0) instanceof DefaultImportSpecifier) {