A tool that generates TypeScript declaration files (.d.ts) from Jars
Because there are certain incompatibilities between Java and TypeScript, definitions MAY NOT always be completely accurate. They will however compile and provide auto complete feature inside a modern text editor supporting typings.
- Interfaces are represented by classes, this will allow you to extend them by using the
newsyntax, as well as show you all its members that need to be implemented - Classes from the package
java.util.functiondon't have their typings generated, asfunctionis a reserved keyword in TypeScript and JavaScript - Classes returning values of Type in the package
java.util.functionwill returnanyinstead - Classes using methods with parameters of Type in the package
java.util.functionwill takeanyinstead - Classes implementing
java.util.Iterator,android.animation.TypeEvaluator,java.lang.Comparabledo not implement those interfaces in the generated definitions for compatibility-related issues
Generate definitions following any of the approaches described below. Once you have run any of commands, you can find the generated typings in dts-generator\out directory.
cd dts-generator
gradlew jar
java -jar build\libs\dts-generator.jar -input %ANDROID_HOME%\platforms\android-<Platform Level (21/22/23/24)>\android.jarcd dts-generator
gradlew jar
java -jar build\libs\dts-generator.jar -input <Path to your Jar>cd dts-generator
gradlew jar
java -jar build\libs\dts-generator.jar -input <jar1> <jar2> <jar3>Open the .aar archive
Extract the classes.jar and any dependencies it may have inside libs/
Rename classes.jar if necessary
java -jar build\libs\dts-generator.jar -input classes.jar dependency-of-classes-jar.jarIn the lib folder there are android support libraries jars which are get from the following git repos: