Skip to content

Commit ed9fb64

Browse files
raidokaldmaRaido Kaldma
andauthored
Fix types, transform now works with array template (works correctly with example from README.md) (#176)
Co-authored-by: Raido Kaldma <raido.kaldma@ria.ee>
1 parent 80498dd commit ed9fb64

1 file changed

Lines changed: 7 additions & 4 deletions

File tree

index.d.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,15 +25,18 @@ export type Transformed<T extends Record<string, any>> = {
2525
[K in keyof T]: Mapped<T[K]>;
2626
};
2727

28+
type TransformResult<T> = T extends readonly [string, any]
29+
? Mapped<T>
30+
: T extends Record<string, any>
31+
? Transformed<T>
32+
: never;
33+
2834
export type XmlInput = string | Uint8Array | ArrayBuffer | Buffer;
2935

3036
export function prettyPrint(
3137
xml: XmlInput,
3238
opts?: { indentSize: number }
3339
): Promise<string>;
3440
export function toJson(xml: XmlInput): Promise<any>;
35-
export function transform<const T extends Record<string, any>>(
36-
xml: XmlInput,
37-
template: T
38-
): Promise<Transformed<T>>;
41+
export function transform<const T>(xml: XmlInput, template: T): Promise<TransformResult<T>>;
3942
export function destroy(): Promise<void>;

0 commit comments

Comments
 (0)