From cd6dca8c632ed0087b7e9068167918d5bd14588d Mon Sep 17 00:00:00 2001 From: Grzegorz Redlicki Date: Tue, 2 Apr 2019 13:32:58 +0200 Subject: [PATCH] Change the type of the error object from "any" to "Error" --- types/xml2js/index.d.ts | 5 +++-- types/xml2js/xml2js-tests.ts | 10 +++++----- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/types/xml2js/index.d.ts b/types/xml2js/index.d.ts index 42fc669da4..fa1d641ab4 100644 --- a/types/xml2js/index.d.ts +++ b/types/xml2js/index.d.ts @@ -6,14 +6,15 @@ // Edward Hinkle // Behind The Math // Claas Ahlrichs +// Grzegorz Redlicki // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped /// 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; diff --git a/types/xml2js/xml2js-tests.ts b/types/xml2js/xml2js-tests.ts index d3298dbf4c..7759ab1d86 100644 --- a/types/xml2js/xml2js-tests.ts +++ b/types/xml2js/xml2js-tests.ts @@ -2,9 +2,9 @@ import xml2js = require('xml2js'); import * as processors from 'xml2js/lib/processors'; import fs = require('fs'); -xml2js.parseString('Hello xml2js!', (err: any, result: any) => { }); +xml2js.parseString('Hello xml2js!', (err: Error, result: any) => { }); -xml2js.parseString('Hello xml2js!', {trim: true}, (err: any, result: any) => { }); +xml2js.parseString('Hello xml2js!', {trim: true}, (err: Error, result: any) => { }); xml2js.parseString('Hello xml2js!', { attrkey: '$', @@ -30,14 +30,14 @@ xml2js.parseString('Hello xml2js!', { attrValueProcessors: undefined, tagNameProcessors: undefined, valueProcessors: undefined -}, (err: any, result: any) => { }); +}, (err: Error, result: any) => { }); xml2js.parseString('Hello xml2js!', { 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'); });