Skip to content

Commit 6bb5ca6

Browse files
committed
write _helpers.d.ts separately
1 parent 57e99d2 commit 6bb5ca6

File tree

3 files changed

+36
-1
lines changed

3 files changed

+36
-1
lines changed

dts-generator/src/main/java/com/telerik/Main.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ private static void validateOutputDir(InputParameters inputParameters, String ne
9393
// .format("We didn't find the folder you specified ( %s ), so it's going to be created!",
9494
// inputParameters.getOutputDir().getAbsolutePath()));
9595
}
96+
9697
inputParameters.setOutputDir(outputDir);
9798
}
9899
}

dts-generator/src/main/java/com/telerik/dts/FileWriter.java

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,4 +55,21 @@ public void write(String content, String fileName) {
5555
}
5656
}
5757
}
58+
59+
public void writeHelperTypings(String content) {
60+
try {
61+
String outFile = this.outDir.getAbsolutePath() + File.separator + "_helpers.d.ts";
62+
this.ps = new PrintStream(new FileOutputStream(outFile, true));
63+
64+
this.ps.print(content);
65+
this.ps.println();
66+
} catch (FileNotFoundException e) {
67+
e.printStackTrace();
68+
}
69+
finally {
70+
if(this.ps != null) {
71+
this.ps.close();
72+
}
73+
}
74+
}
5875
}

dts-generator/src/main/java/com/telerik/dts/Generator.java

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
import java.io.File;
88
import java.io.IOException;
9+
import java.util.ArrayList;
910
import java.util.List;
1011

1112
/**
@@ -29,14 +30,30 @@ public void start(InputParameters inputParameters) throws IOException {
2930
}
3031

3132
private void generateDts() {
32-
while(ClassRepo.hasNext()) {
33+
writeHelperTypings();
34+
35+
while (ClassRepo.hasNext()) {
3336
List<JavaClass> classFiles = ClassRepo.getNextClassGroup();
3437
String generatedContent = this.dtsApi.generateDtsContent(classFiles);
3538

3639
this.fw.write(generatedContent, classFiles.get(0).getFileName()/*fileName*/);
3740
}
3841
}
3942

43+
private void writeHelperTypings() {
44+
45+
List<String> helperTypings = new ArrayList<>();
46+
helperTypings.add("declare module native {\n" +
47+
"\texport class Array<T> {\n" +
48+
"\t\tpublic constructor();\n" +
49+
"\t}\n" +
50+
"}\n");
51+
52+
for (String helper : helperTypings) {
53+
this.fw.writeHelperTypings(helper);
54+
}
55+
}
56+
4057
private void loadJavaClasses(List<File> jars) throws IOException {
4158
for (File file : jars) {
4259
if (file.exists()) {

0 commit comments

Comments
 (0)