Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeScript types #39

Open
gauthierm opened this issue Apr 6, 2021 · 1 comment
Open

TypeScript types #39

gauthierm opened this issue Apr 6, 2021 · 1 comment

Comments

@gauthierm
Copy link

This package has a simple interface and TypeScript types can be added by including an index.d.ts file containing:

  interface XMLElement {
    name: string;
    attributes: {
      [name: string]: string;
    };
    value: string;
    children: XMLElement[];
  }

  export default class XMLParser {
    constructor();
    public parseFromString(string: string): XMLElement;
    public toString(xml: XMLElement): string;
    public getElementsByTagName(tagName: string): XMLElement[];
  }
@federico-pi
Copy link

For React users:

declare module 'react-xml-parser' {
  interface XMLElement {
    name: string;
    attributes: {
      [name: string]: string;
    };
    value: string;
    children: XMLElement[];

    getElementsByTagName(tagName: string): XMLElement[];
  }

  export default class XMLParser {
    constructor();
    public parseFromString(string: string): XMLElement;
    public toString(xml: XMLElement): string;
  }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants