Skip to content

Commit

Permalink
fix(types): make build and parse generic (#594)
Browse files Browse the repository at this point in the history
* fix(types): make `build` and `parse` generic

* fix: account for array types
  • Loading branch information
sarahdayan committed Sep 20, 2023
1 parent ae99fc6 commit 75acbc5
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/fxp.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,11 @@ type ValidationError = {
};
};

type GenericObjectOrArray<TValue> = Record<string, unknown> | TValue[];

export class XMLParser {
constructor(options?: X2jOptionsOptional);
parse(xmlData: string | Buffer ,validationOptions?: validationOptionsOptional | boolean): any;
parse<TObject extends GenericObjectOrArray<unknown> = GenericObjectOrArray<unknown>>(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;
Expand All @@ -104,5 +106,5 @@ export class XMLValidator{
}
export class XMLBuilder {
constructor(options?: XmlBuilderOptionsOptional);
build(jObj: any): any;
build<TObject extends GenericObjectOrArray<unknown> = GenericObjectOrArray<unknown>>(jObj: TObject): string;
}

0 comments on commit 75acbc5

Please sign in to comment.