Merge pull request #25829 from ts2do/master

xmldoc: Corrected, expanded, and refined typings
This commit is contained in:
Daniel Rosenwasser
2018-05-22 23:29:37 -07:00
committed by GitHub

View File

@@ -6,31 +6,35 @@
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped): // TypeScript Version: 2.1
export class XmlDocument extends XmlElement {
constructor(xmlString: string);
constructor(xml: string);
doctype: string;
}
export class XmlElement {
constructor(tag: XmlElement);
export type XmlNode = XmlElement | XmlTextNode | XmlCDataNode | XmlCommentNode;
export class XmlElement {
constructor(tag: XmlTag);
type: 'element';
name: string;
attr: XmlAttributes;
val: string;
children: XmlElement[];
firstChild: XmlElement;
lastChild: XmlElement;
children: XmlNode[];
firstChild: XmlNode | null;
lastChild: XmlNode | null;
line: number;
column: number;
position: number;
startTagPosition: number;
eachChild(func: (child: XmlElement, index?: number, array?: XmlElement[]) => void): void;
childNamed(name: string): XmlElement;
eachChild(iterator: (child: XmlElement, index: number, array: XmlNode[]) => void): void;
eachChild<T>(iterator: (this: T, child: XmlElement, index: number, array: XmlNode[]) => void, context: T): void;
childNamed(name: string): XmlElement | undefined;
childrenNamed(name: string): XmlElement[];
childWithAttribute(name: string, value?: string): XmlElement;
descendantWithPath(path: string): XmlElement;
valueWithPath(path: string): string;
childWithAttribute(name: string, value?: string | null): XmlElement | undefined;
descendantWithPath(path: string): XmlElement | undefined;
valueWithPath(path: string): string | undefined;
toString(opts?: XmlOptions): string;
toStringWithIndent(indent: string, opts?: XmlOptions): string;
}
@@ -38,6 +42,9 @@ export class XmlElement {
export class XmlTextNode {
constructor(text: string);
type: 'text';
text: string;
toString(opts?: XmlOptions): string;
toStringWithIndent(indent: string, opts?: XmlOptions): string;
}
@@ -45,6 +52,9 @@ export class XmlTextNode {
export class XmlCDataNode {
constructor(cdata: string);
type: 'cdata';
cdata: string;
toString(opts?: XmlOptions): string;
toStringWithIndent(indent: string, opts?: XmlOptions): string;
}
@@ -52,6 +62,9 @@ export class XmlCDataNode {
export class XmlCommentNode {
constructor(comment: string);
type: 'comment';
comment: string;
toString(opts?: XmlOptions): string;
toStringWithIndent(indent: string, opts?: XmlOptions): string;
}