Downstream is a legitimate question. Please take the time to learn it before assuming that I am mixing my languages ββlike some newb programming!
I need to know if it is possible to import a Java object (in particular, the enum class) into a Typescript script.
I searched googled but didn't find anything.
ErrorCodeAuthority is designed to create custom standard errors emanating from our service for every known error with given messages (some parameterized, some not), http status codes, etc., defined in one place.
Our javascript code has
var JavaErrorCodeAuthority = Java.type("com.domain.ErrorCodeAuthority");
Is it possible to do the same in Typescript?
Edit based on answer below
I stated the following:
declare module Java {
export enum ErrorCodeAuthority {
ENTITY_NOT_FOUND,
HTTP_VERB_NOT_SUPPORTED,
BAD_REQUEST,
}
export function type(arg: "com.domain.ErrorCodeAuthority"): ErrorCodeAuthority;
export function type(arg: string): any;
}
var JavaErrorCodeAuthority = Java.type("com.domain.ErrorCodeAuthority");
and I am trying to use the new type as follows:
export class HttpFailResult extends HttpResult {
constructor(public errorCode : Java.ErrorCodeAuthority, public userParams? : UserParam[]) {
super(errorCode.httpStatus.value(), errorCode.toString());
}
}
, grunt js:
error TS2339: Property 'httpStatus' does not exist on type 'ErrorCodeAuthority'.
( HttpResult - , number http code and a body. HttpStatus, in the Java enum, is of type org.springframework.http.HttpStatus`).
export function type(arg: "com.domain.ErrorCodeAuthority"): ErrorCodeAuthority;, .
2
nashorn, .