mirror of
https://github.com/FlipsideCrypto/DefinitelyTyped.git
synced 2026-02-06 10:56:53 +00:00
🤖 Merge PR #46722 xml2json: replace types of {} with Record<string, unknown> by @garyking
* use Record # Conflicts: # types/xml2json/index.d.ts * fix * use generics * fix lint errors from using generics only once
This commit is contained in:
parent
d8fc3f8dcf
commit
d4e7c79bb1
4
types/xml2json/index.d.ts
vendored
4
types/xml2json/index.d.ts
vendored
@ -7,9 +7,9 @@
|
||||
/// <reference types="node" />
|
||||
|
||||
export function toJson(xml: string | Buffer, options?: { object?: false } & JsonOptions): string;
|
||||
export function toJson(xml: string | Buffer, options?: { object: true } & JsonOptions): {};
|
||||
export function toJson(xml: string | Buffer, options?: { object: true } & JsonOptions): { [key: string]: unknown };
|
||||
|
||||
export function toXml(json: {} | string | Buffer, options?: XmlOptions): string;
|
||||
export function toXml(json: { [key: string]: unknown } | string | Buffer, options?: XmlOptions): string;
|
||||
|
||||
export interface XmlOptions {
|
||||
/**
|
||||
|
||||
@ -9,7 +9,7 @@ const jsonString: string = parser.toJson(xml);
|
||||
xml = parser.toXml(jsonString);
|
||||
|
||||
// xml to json in object mode and JsonOptions
|
||||
const jsonObject: {} = parser.toJson(xml, {
|
||||
const jsonObject: { [key: string]: unknown } = parser.toJson(xml, {
|
||||
object: true,
|
||||
reversible: false,
|
||||
coerce: false,
|
||||
@ -18,6 +18,9 @@ const jsonObject: {} = parser.toJson(xml, {
|
||||
arrayNotation: false,
|
||||
});
|
||||
|
||||
const a = parser.toJson(xml, { object: true }) as { [key: string]: string };
|
||||
const b = parser.toJson(xml, { object: true }) as { [key: string]: number };
|
||||
|
||||
// json to xml with XmlOptions
|
||||
xml = parser.toXml(jsonObject, {
|
||||
sanitize: true,
|
||||
|
||||
Loading…
Reference in New Issue
Block a user