mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-06-28 14:20:12 +00:00
Move all packages to a types directory
This commit is contained in:
71
types/java/index.d.ts
vendored
Normal file
71
types/java/index.d.ts
vendored
Normal file
@@ -0,0 +1,71 @@
|
||||
// Type definitions for java 0.7.2
|
||||
// Project: https://github.com/joeferner/node-java
|
||||
// Definitions by: Jim Lloyd <https://github.com/jimlloyd>, Kentaro Teramoto <https://github.com/hrl7>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
/// <reference types="node" />
|
||||
|
||||
// This is the core API exposed by https://github.com/joeferner/java.
|
||||
// To get the full power of Typescript with Java, see https://github.com/RedSeal-co/ts-java.
|
||||
|
||||
declare var NodeJavaCore: NodeJavaCore.NodeAPI;
|
||||
export = NodeJavaCore;
|
||||
|
||||
declare namespace NodeJavaCore {
|
||||
export interface Callback<T> {
|
||||
(err?: Error, result?: T): void;
|
||||
}
|
||||
|
||||
interface Promisify {
|
||||
(funct: Function, receiver?: any): Function;
|
||||
}
|
||||
|
||||
interface AsyncOptions {
|
||||
syncSuffix: string;
|
||||
asyncSuffix?: string;
|
||||
promiseSuffix?: string;
|
||||
promisify?: Promisify;
|
||||
}
|
||||
|
||||
interface ProxyFunctions {
|
||||
[index: string]: Function;
|
||||
}
|
||||
|
||||
// *NodeAPI* declares methods & members exported by the node java module.
|
||||
interface NodeAPI {
|
||||
classpath: string[];
|
||||
options: string[];
|
||||
asyncOptions: AsyncOptions;
|
||||
nativeBindingLocation: string;
|
||||
|
||||
callMethod(instance: any, className: string, methodName: string, args: any[], callback: Callback<any>): void;
|
||||
callMethodSync(instance: any, className: string, methodName: string, ...args: any[]): any;
|
||||
callStaticMethod(className: string, methodName: string, ...args: Array<any|Callback<any>>): void;
|
||||
callStaticMethodSync(className: string, methodName: string, ...args: any[]): any;
|
||||
getStaticFieldValue(className: string, fieldName: string): any;
|
||||
setStaticFieldValue(className: string, fieldName: string, newValue: any): void;
|
||||
instanceOf(javaObject: any, className: string): boolean;
|
||||
registerClient(before: (cb: Callback<void>) => void, after?: (cb: Callback<void>) => void): void;
|
||||
registerClientP(beforeP: () => Promise<void>, afterP?: () => Promise<void>): void;
|
||||
ensureJvm(done: Callback<void>): void;
|
||||
ensureJvm(): Promise<void>;
|
||||
isJvmCreated(): boolean;
|
||||
|
||||
newByte(val: number): any;
|
||||
newChar(val: string|number): any;
|
||||
newDouble(val: number): any;
|
||||
newShort(val: number): any;
|
||||
newLong(val: number): any;
|
||||
newFloat(val: number): any;
|
||||
newDouble(val: number): any;
|
||||
|
||||
import(className: string): any;
|
||||
newInstance(className: string, ...args: any[]): void;
|
||||
newInstanceSync(className: string, ...args: any[]): any;
|
||||
newInstanceP(className: string, ...args: any[]): Promise<any>;
|
||||
newArray<T>(className: string, arg: any[]): any;
|
||||
getClassLoader(): any;
|
||||
|
||||
newProxy(interfaceName: string, functions: ProxyFunctions): any;
|
||||
}
|
||||
}
|
||||
33
types/java/java-tests.ts
Normal file
33
types/java/java-tests.ts
Normal file
@@ -0,0 +1,33 @@
|
||||
///<reference types="bluebird"/>
|
||||
|
||||
import java = require('java');
|
||||
import BluePromise = require('bluebird');
|
||||
|
||||
java.asyncOptions = {
|
||||
syncSuffix: 'Sync',
|
||||
asyncSuffix: '',
|
||||
promiseSuffix: 'P',
|
||||
promisify: BluePromise.promisify
|
||||
};
|
||||
// todo: figure out why promise doesn't work here
|
||||
/* java.registerClientP((): Promise<void> => {
|
||||
return BluePromise.resolve();
|
||||
}); */
|
||||
|
||||
interface ProxyFunctions {
|
||||
[index: string]: Function;
|
||||
}
|
||||
|
||||
java.ensureJvm()
|
||||
.then(() => {
|
||||
|
||||
// java.d.ts does not declare any Java types.
|
||||
// We can import a java class, but we don't know the shape of the class here, so must use any
|
||||
var Boolean: any = java.import('java.lang.Boolean');
|
||||
|
||||
var functions: ProxyFunctions = {
|
||||
accept: function(t: any): void { },
|
||||
andThen: function(after: any): any {}
|
||||
};
|
||||
var proxy: any = java.newProxy('java.util.function.Consumer', functions);
|
||||
});
|
||||
22
types/java/tsconfig.json
Normal file
22
types/java/tsconfig.json
Normal file
@@ -0,0 +1,22 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": false,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"java-tests.ts"
|
||||
]
|
||||
}
|
||||
Reference in New Issue
Block a user