Merge pull request #34394 from redlickigrzegorz/bugfix/exact-type-for-error-object

@types/xml2js change the type of the Error object
This commit is contained in:
Benjamin Lichtman
2019-04-02 16:05:14 -07:00
committed by GitHub
2 changed files with 8 additions and 7 deletions
+3 -2
View File
@@ -6,14 +6,15 @@
// Edward Hinkle <https://github.com/edwardhinkle>
// Behind The Math <https://github.com/BehindTheMath>
// Claas Ahlrichs <https://github.com/claasahl>
// Grzegorz Redlicki <https://github.com/redlickigrzegorz>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
/// <reference types="node"/>
import { EventEmitter } from 'events';
import * as processors from './lib/processors';
export function parseString(xml: convertableToString, callback: (err: any, result: any) => void): void;
export function parseString(xml: convertableToString, options: OptionsV2, callback: (err: any, result: any) => void): void;
export function parseString(xml: convertableToString, callback: (err: Error, result: any) => void): void;
export function parseString(xml: convertableToString, options: OptionsV2, callback: (err: Error, result: any) => void): void;
export const defaults: {
'0.1': Options;
+5 -5
View File
@@ -2,9 +2,9 @@ import xml2js = require('xml2js');
import * as processors from 'xml2js/lib/processors';
import fs = require('fs');
xml2js.parseString('<root>Hello xml2js!</root>', (err: any, result: any) => { });
xml2js.parseString('<root>Hello xml2js!</root>', (err: Error, result: any) => { });
xml2js.parseString('<root>Hello xml2js!</root>', {trim: true}, (err: any, result: any) => { });
xml2js.parseString('<root>Hello xml2js!</root>', {trim: true}, (err: Error, result: any) => { });
xml2js.parseString('<root>Hello xml2js!</root>', {
attrkey: '$',
@@ -30,14 +30,14 @@ xml2js.parseString('<root>Hello xml2js!</root>', {
attrValueProcessors: undefined,
tagNameProcessors: undefined,
valueProcessors: undefined
}, (err: any, result: any) => { });
}, (err: Error, result: any) => { });
xml2js.parseString('<root>Hello xml2js!</root>', {
attrNameProcessors: [processors.firstCharLowerCase, xml2js.processors.normalize],
attrValueProcessors: [processors.normalize],
tagNameProcessors: [processors.stripPrefix],
valueProcessors: [processors.parseBooleans, processors.parseNumbers]
}, (err: any, result: any) => { });
}, (err: Error, result: any) => { });
let builder = new xml2js.Builder({
renderOpts: {
@@ -81,7 +81,7 @@ v2Defaults.async = false;
v2Defaults.chunkSize = 20000;
fs.readFile(__dirname + '/foo.xml', (err, data) => {
parser.parseString(data, (err: any, result: any) => {
parser.parseString(data, (err: Error, result: any) => {
console.dir(result);
console.log('Done');
});