Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions appformer-js/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,15 +43,15 @@
"babel-preset-react": "6.24.1",
"circular-dependency-plugin": "5.0.2",
"clean-webpack-plugin": "0.1.19",
"jest": "23.5.0",
"jest": "^27.5.1",
"jest-junit": "6.3.0",
"prettier": "1.14.2",
"ts-jest": "23.1.3",
"ts-loader": "4.4.2",
"ts-jest": "^27.1.5",
"ts-loader": "^8.4.0",
"tslint": "5.11.0",
"tslint-config-prettier": "1.15.0",
"tslint-react": "3.6.0",
"typescript": "2.9.2",
"typescript": "^4.9.5",
"watch": "1.0.2",
"webpack": "4.15.1",
"webpack-cli": "3.0.8",
Expand Down
2 changes: 1 addition & 1 deletion appformer-js/src/appformer/AppFormer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ export class AppFormer {
* The event object.
*/
// tslint:disable-next-line
public fireEvent<T>(obj: Portable<T>): void {}
public fireEvent<T extends Portable<T>>(obj: Portable<T>): void {}

/**
* Executes an RPC call to an Errai Remote.
Expand Down
2 changes: 1 addition & 1 deletion appformer-js/src/appformer/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ export function render(element: Element, container: HTMLElement, callback = ():
singleton!.render(element, container, callback);
}

export function fireEvent<T>(obj: Portable<T>) {
export function fireEvent<T extends Portable<T>>(obj: Portable<T>) {
singleton!.fireEvent(marshall(obj) as any);
}

Expand Down
9 changes: 8 additions & 1 deletion appformer-js/src/java-wrappers/JavaOptional.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,14 @@ export class JavaOptional<T> extends JavaWrapper<T | undefined> {
}

public set(val: ((current: T | undefined) => T | undefined) | T | undefined): void {
if (typeof val === "function") {
// Type guard to check if val is an updater function
const isUpdaterFunction = (
v: ((current: T | undefined) => T | undefined) | T | undefined
): v is (current: T | undefined) => T | undefined => {
return typeof v === "function";
};

if (isUpdaterFunction(val)) {
this._value = val(this.get());
} else {
this._value = val;
Expand Down
2 changes: 1 addition & 1 deletion appformer-js/src/java-wrappers/JavaWrapperUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ export class JavaWrapperUtils {

public static isJavaType(fqcn: string): boolean {
for (const type in JavaType) {
if (JavaType[type] === fqcn) {
if (JavaType[type as keyof typeof JavaType] === fqcn) {
return true;
}
}
Expand Down
4 changes: 2 additions & 2 deletions appformer-js/src/marshalling/Marshalling.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import { ErraiObjectConstants } from "./model/ErraiObjectConstants";
* @param obj
*/

export function marshall<T>(obj: Portable<T>): string | null {
export function marshall<T extends Portable<T>>(obj: Portable<T>): string | null {
if (obj === null || obj === undefined) {
return null;
}
Expand All @@ -42,7 +42,7 @@ export function marshall<T>(obj: Portable<T>): string | null {
* @param oracle
* A map containing fqcns as keys and a function returning an empty Portable<T> associated with that fqcn.
*/
export function unmarshall<T>(json: string, oracle: Map<string, () => Portable<any>>): Portable<T> | null | void {
export function unmarshall<T extends Portable<T>>(json: string, oracle: Map<string, () => Portable<any>>): Portable<T> | null | void {
if (json === null || json === undefined) {
return undefined;
}
Expand Down
4 changes: 2 additions & 2 deletions appformer-js/src/marshalling/MarshallingContext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,13 @@ export class MarshallingContext {
return this.objContext.get(this.unwrap(key))!;
}

private unwrap(key: Portable<any>) {
private unwrap(key: Portable<any>): Portable<any> {
if (JavaWrapper.extendsJavaWrapper(key)) {
// When handling wrapped values, we use the raw typescript value as cache key.
// This is needed because in the marshalling flow we wrap the values automatically
// if they represent a Java type, creating a new wrapper object every time. If we use the wrapper
// object directly, the value will never be found in cache, because it'll always be a different pointer
return key.get();
return key.get() as Portable<any>;
}

return key;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ abstract class JavaCollectionMarshaller<T extends Iterable<Portable<any> | null>

const unmarshalledValues = [];
for (const element of Array.from(collection)) {
unmarshalledValues.push(MarshallerProvider.getForObject(element).unmarshall(element, ctx));
unmarshalledValues.push(MarshallerProvider.getForObject(element as Portable<any>).unmarshall(element, ctx));
}

const javaCollection = this.fromArray(unmarshalledValues);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1409,7 +1409,7 @@ describe("unmarshall", () => {
const marshalledInput = marshaller.marshall(input, new MarshallingContext())!;

// remove its fqcn
delete marshalledInput[ErraiObjectConstants.ENCODED_TYPE];
delete (marshalledInput as any)[ErraiObjectConstants.ENCODED_TYPE];

expect(() => marshaller.unmarshall(marshalledInput, unmarshallContext)).toThrowError();
});
Expand Down
4 changes: 2 additions & 2 deletions appformer-js/src/util/DomUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@ function searchChildren(args: {
const stack = [root];
stack.push(root);

const accepted = new Set();
const visited = new Set();
const accepted = new Set<HTMLElement>();
const visited = new Set<HTMLElement>();

while (stack.length > 0) {
node = stack.pop()!;
Expand Down
2 changes: 1 addition & 1 deletion appformer-js/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"./src"
],
"compilerOptions": {
"outDir": "./",
"outDir": "./dist",
"lib": [
"es6",
"dom"
Expand Down
Loading