Skip to content

Commit 75acbc5

Browse files
authored
fix(types): make build and parse generic (#594)
* fix(types): make `build` and `parse` generic * fix: account for array types
1 parent ae99fc6 commit 75acbc5

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

Diff for: src/fxp.d.ts

+4-2
Original file line numberDiff line numberDiff line change
@@ -88,9 +88,11 @@ type ValidationError = {
8888
};
8989
};
9090

91+
type GenericObjectOrArray<TValue> = Record<string, unknown> | TValue[];
92+
9193
export class XMLParser {
9294
constructor(options?: X2jOptionsOptional);
93-
parse(xmlData: string | Buffer ,validationOptions?: validationOptionsOptional | boolean): any;
95+
parse<TObject extends GenericObjectOrArray<unknown> = GenericObjectOrArray<unknown>>(xmlData: string | Buffer ,validationOptions?: validationOptionsOptional | boolean): TObject;
9496
/**
9597
* Add Entity which is not by default supported by this library
9698
* @param entityIndentifier {string} Eg: 'ent' for &ent;
@@ -104,5 +106,5 @@ export class XMLValidator{
104106
}
105107
export class XMLBuilder {
106108
constructor(options?: XmlBuilderOptionsOptional);
107-
build(jObj: any): any;
109+
build<TObject extends GenericObjectOrArray<unknown> = GenericObjectOrArray<unknown>>(jObj: TObject): string;
108110
}

0 commit comments

Comments
 (0)