From 75acbc59ffccf79e92bed98db88dc09621d0ba43 Mon Sep 17 00:00:00 2001 From: Sarah Dayan <5370675+sarahdayan@users.noreply.github.com> Date: Wed, 20 Sep 2023 05:56:28 +0200 Subject: [PATCH] fix(types): make `build` and `parse` generic (#594) * fix(types): make `build` and `parse` generic * fix: account for array types --- src/fxp.d.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/fxp.d.ts b/src/fxp.d.ts index d622f27e..68bbc3d8 100644 --- a/src/fxp.d.ts +++ b/src/fxp.d.ts @@ -88,9 +88,11 @@ type ValidationError = { }; }; +type GenericObjectOrArray = Record | TValue[]; + export class XMLParser { constructor(options?: X2jOptionsOptional); - parse(xmlData: string | Buffer ,validationOptions?: validationOptionsOptional | boolean): any; + parse = GenericObjectOrArray>(xmlData: string | Buffer ,validationOptions?: validationOptionsOptional | boolean): TObject; /** * Add Entity which is not by default supported by this library * @param entityIndentifier {string} Eg: 'ent' for &ent; @@ -104,5 +106,5 @@ export class XMLValidator{ } export class XMLBuilder { constructor(options?: XmlBuilderOptionsOptional); - build(jObj: any): any; + build = GenericObjectOrArray>(jObj: TObject): string; }