From 4662d28b4aa01065db29d47059ab33183b83d3b2 Mon Sep 17 00:00:00 2001 From: Horiuchi_H Date: Thu, 27 Oct 2016 17:02:10 +0900 Subject: [PATCH 1/4] feat: update xml2js type definition --- xml2js/index.d.ts | 34 +++++----------------------- xml2js/tsconfig.json | 4 ++-- xml2js/xml2js-tests.ts | 50 +++++++++++++++++++++++++++++++++++++++--- 3 files changed, 54 insertions(+), 34 deletions(-) diff --git a/xml2js/index.d.ts b/xml2js/index.d.ts index e9d4e12ad0..0e180f7ba8 100644 --- a/xml2js/index.d.ts +++ b/xml2js/index.d.ts @@ -9,7 +9,7 @@ export = xml2js; declare namespace xml2js { function parseString(xml: string, callback: (err: any, result: any) => void): void; - function parseString(xml: string, options: Options, callback: (err: any, result: any) => void): void; + function parseString(xml: string, options: OptionsV2, callback: (err: any, result: any) => void): void; var defaults: { '0.1': Options; @@ -17,41 +17,15 @@ declare namespace xml2js { } class Builder { - constructor(options?: BuilderOptions); + constructor(options?: OptionsV2); buildObject(rootObj: any): string; } class Parser { - constructor(options?: Options); - processAsync(): any; - assignOrPush(obj: any, key: string, newValue: any): any; - reset(): any; + constructor(options?: OptionsV2); parseString(str: string, cb?: Function): void; } - interface RenderOptions { - indent?: string; - newline?: string; - pretty?: boolean; - } - - interface XMLDeclarationOptions { - encoding?: string; - standalone?: boolean; - version?: string; - } - - interface BuilderOptions { - doctype?: any; - headless?: boolean; - indent?: string; - newline?: string; - pretty?: boolean; - renderOpts?: RenderOptions; - rootName?: string; - xmldec?: XMLDeclarationOptions; - } - interface Options { async?: boolean; attrkey?: string; @@ -66,6 +40,7 @@ declare namespace xml2js { explicitChildren?: boolean; explicitRoot?: boolean; ignoreAttrs?: boolean; + includeWhiteChars?: boolean; mergeAttrs?: boolean; normalize?: boolean; normalizeTags?: boolean; @@ -96,3 +71,4 @@ declare namespace xml2js { cdata?: boolean; } } + diff --git a/xml2js/tsconfig.json b/xml2js/tsconfig.json index 61e4e5e52f..8e23bd3395 100644 --- a/xml2js/tsconfig.json +++ b/xml2js/tsconfig.json @@ -3,7 +3,7 @@ "module": "commonjs", "target": "es6", "noImplicitAny": true, - "strictNullChecks": false, + "strictNullChecks": true, "baseUrl": "../", "typeRoots": [ "../" @@ -16,4 +16,4 @@ "index.d.ts", "xml2js-tests.ts" ] -} \ No newline at end of file +} diff --git a/xml2js/xml2js-tests.ts b/xml2js/xml2js-tests.ts index 3e3981156e..38306d9bb4 100644 --- a/xml2js/xml2js-tests.ts +++ b/xml2js/xml2js-tests.ts @@ -1,9 +1,35 @@ import xml2js = require('xml2js'); -xml2js.parseString("Hello xml2js!", (err: any, result: any) => { }); +xml2js.parseString('Hello xml2js!', (err: any, result: any) => { }); -xml2js.parseString("Hello xml2js!", {trim: true}, (err: any, result: any) => { }); +xml2js.parseString('Hello xml2js!', {trim: true}, (err: any, result: any) => { }); + +xml2js.parseString('Hello xml2js!', { + attrkey: '$', + charkey: '_', + explicitCharkey: false, + trim: false, + normalizeTags: false, + explicitRoot: true, + emptyTag: '', + explicitArray: true, + ignoreAttrs: false, + mergeAttrs: false, + validator: undefined, + xmlns: false, + explicitChildren: false, + childkey: '$$', + preserveChildrenOrder: false, + charsAsChildren: false, + includeWhiteChars: false, + async: false, + strict: true, + attrNameProcessors: undefined, + attrValueProcessors: undefined, + tagNameProcessors: undefined, + valueProcessors: undefined +}, (err: any, result: any) => { }); var builder = new xml2js.Builder({ renderOpts: { @@ -11,6 +37,23 @@ var builder = new xml2js.Builder({ } }); +var builder = new xml2js.Builder({ + rootName: 'root', + renderOpts: { + pretty: true, + indent: ' ', + newline: '\n' + }, + xmldec: { + version: '1.0', + encoding: 'UTF-8', + standalone: true + }, + doctype: { ext: 'hello.dtd' }, + headless: false, + cdata: false +}); + var outString = builder.buildObject({ 'hello': 'xml2js!' }); @@ -22,4 +65,5 @@ v1Defaults.async = true; var v2Defaults = xml2js.defaults['0.2']; v2Defaults.async = false; -v2Defaults.chunkSize = 20000; \ No newline at end of file +v2Defaults.chunkSize = 20000; + From 849bb4695bfed2de045ee620e2ef5f8538df6f3a Mon Sep 17 00:00:00 2001 From: Nikita Mikhailov Date: Tue, 15 Nov 2016 00:31:43 +0700 Subject: [PATCH 2/4] Add missing definitions for libphonenumber --- google-libphonenumber/index.d.ts | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/google-libphonenumber/index.d.ts b/google-libphonenumber/index.d.ts index 4a0f865373..28f72f67a3 100644 --- a/google-libphonenumber/index.d.ts +++ b/google-libphonenumber/index.d.ts @@ -15,11 +15,21 @@ declare namespace libphonenumber { interface PhoneNumber { } + export module PhoneNumberUtil { + export enum ValidationResult { + IS_POSSIBLE, + INVALID_COUNTRY_CODE, + TOO_SHORT, + TOO_LONG + } + } + export class PhoneNumberUtil { static getInstance(): PhoneNumberUtil parse(number: string, region: string): PhoneNumber; isValidNumber(phoneNumber: PhoneNumber): boolean; isPossibleNumber(phoneNumber: PhoneNumber): boolean; + isPossibleNumberWithReason(phoneNumber: PhoneNumber): PhoneNumberUtil.ValidationResult; isValidNumberForRegion(phoneNumber: PhoneNumber, region: string): boolean; getRegionCodeForNumber(phoneNumber: PhoneNumber): string; isNANPACountry(regionCode: string): boolean; From e8ba41e4e2d402c16a47b8443cacc9cd861cce67 Mon Sep 17 00:00:00 2001 From: Johannes Fahrenkrug Date: Fri, 11 Nov 2016 15:21:45 -0500 Subject: [PATCH 3/4] Add type definition for keymirror --- keymirror/index.d.ts | 7 +++++++ keymirror/keymirror-tests.ts | 3 +++ keymirror/tsconfig.json | 19 +++++++++++++++++++ 3 files changed, 29 insertions(+) create mode 100644 keymirror/index.d.ts create mode 100644 keymirror/keymirror-tests.ts create mode 100644 keymirror/tsconfig.json diff --git a/keymirror/index.d.ts b/keymirror/index.d.ts new file mode 100644 index 0000000000..e8c28c6d34 --- /dev/null +++ b/keymirror/index.d.ts @@ -0,0 +1,7 @@ +// Type definitions for keymirror 0.1.1 +// Project: https://github.com/STRML/keyMirror +// Definitions by: Johannes Fahrenkrug +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +declare function KeyMirror(obj: Object): Object; +export = KeyMirror; diff --git a/keymirror/keymirror-tests.ts b/keymirror/keymirror-tests.ts new file mode 100644 index 0000000000..ace29f9947 --- /dev/null +++ b/keymirror/keymirror-tests.ts @@ -0,0 +1,3 @@ +import keyMirror = require('keymirror'); + +keyMirror({key1: null, key2: null}); diff --git a/keymirror/tsconfig.json b/keymirror/tsconfig.json new file mode 100644 index 0000000000..ce57da7581 --- /dev/null +++ b/keymirror/tsconfig.json @@ -0,0 +1,19 @@ +{ + "compilerOptions": { + "module": "commonjs", + "target": "es6", + "noImplicitAny": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "keymirror-tests.ts" + ] +} From 71ddd7d62b56281185bcf49cc7c8b4762d4e712e Mon Sep 17 00:00:00 2001 From: Johannes Fahrenkrug Date: Mon, 14 Nov 2016 16:03:55 -0500 Subject: [PATCH 4/4] Improve type definition for keymirror --- keymirror/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/keymirror/index.d.ts b/keymirror/index.d.ts index e8c28c6d34..1f2b6c01da 100644 --- a/keymirror/index.d.ts +++ b/keymirror/index.d.ts @@ -3,5 +3,5 @@ // Definitions by: Johannes Fahrenkrug // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -declare function KeyMirror(obj: Object): Object; +declare function KeyMirror(obj: {}): { [key: string]: string }; export = KeyMirror;