You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
varjava=require("java");java.classpath.push("pngLibrary.jar");constPngColorType=java.import("com.fileformats.png.PngColorType");varcolorType: PngColorType=newPngColorType();// error here
Is there any support for strong typing, code completion and so on?
The text was updated successfully, but these errors were encountered:
velara3
changed the title
Is there a way to add code completion or strong typing with Typescript?
Is there a way to add code completion or strong typing for objects with Typescript?
May 1, 2024
Not that I am aware of but there are a few tools out there that generate .d.ts files from a Java source. You could try to use one of those to generate typings for your projects and get type-checking support.
Your other option is to do it manually like I do. This also helps to keep track of where JS and Java mix as anything I do not add to this list will throw an error.
exportnamespaceJavaClasses{exportinterfaceJavaClass{(...args: unknown[]): any;new(...args: unknown[]): any;[key: string]: any;}/* eslint-disable @typescript-eslint/no-empty-interface */exportinterfaceFooextendsJavaClass{}exportinterfaceFileextendsJavaClass{getParentFile(): JavaClasses.File;getAbsolutePath(): string;}}// Somewhere in your codereturnjava.import("java.io.File")asJavaClasses.File;
Definitely not a perfect solution. Did the trick for me.
I'm using this project in a nodejs project in vscode using Typescript..
I've got it to work with a custom class / jar / library and now I'm wondering if there's a way to add strong typing or code completion in vscode.
For example, I have the following working code:
But if I type the variable like so:
I get the following error:
Is there any support for strong typing, code completion and so on?
The text was updated successfully, but these errors were encountered: