From 060e346f624fbc533f0e2c4e54f7c23a7b46757c Mon Sep 17 00:00:00 2001 From: Ben Stevens Date: Fri, 23 Feb 2018 13:04:58 +0000 Subject: [PATCH] add types for jsontoxml --- types/jsontoxml/index.d.ts | 22 ++++++++++++++++++++++ types/jsontoxml/jsontoxml-tests.ts | 10 ++++++++++ types/jsontoxml/tsconfig.json | 24 ++++++++++++++++++++++++ types/jsontoxml/tslint.json | 1 + 4 files changed, 57 insertions(+) create mode 100644 types/jsontoxml/index.d.ts create mode 100644 types/jsontoxml/jsontoxml-tests.ts create mode 100644 types/jsontoxml/tsconfig.json create mode 100644 types/jsontoxml/tslint.json diff --git a/types/jsontoxml/index.d.ts b/types/jsontoxml/index.d.ts new file mode 100644 index 0000000000..f683050031 --- /dev/null +++ b/types/jsontoxml/index.d.ts @@ -0,0 +1,22 @@ +// Type definitions for jsontoxml 1.0 +// Project: https://github.com/soldair/node-jsontoxml +// Definitions by: benstevens48 +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +declare namespace jsontoxml { + function escape(str: string): string; + function cdata(str: string): string; + interface JsonToXmlOptions { + escape?: boolean; + xmlHeader?: boolean | {standalone?: boolean}; + docType?: string; + prettyPrint?: boolean; + indent?: string; + removeIllegalNameCharacters?: boolean; + html?: boolean; + } +} + +declare function jsontoxml(data: any, options?: jsontoxml.JsonToXmlOptions): string; + +export = jsontoxml; diff --git a/types/jsontoxml/jsontoxml-tests.ts b/types/jsontoxml/jsontoxml-tests.ts new file mode 100644 index 0000000000..98b9da5552 --- /dev/null +++ b/types/jsontoxml/jsontoxml-tests.ts @@ -0,0 +1,10 @@ +import jsontoxml = require('jsontoxml'); + +// $ExpectType string +jsontoxml({foo: 'bar'}, {escape: true, xmlHeader: true}); + +// $ExpectType string +jsontoxml.escape('&test'); + +// $ExpectType string +jsontoxml.cdata('test'); diff --git a/types/jsontoxml/tsconfig.json b/types/jsontoxml/tsconfig.json new file mode 100644 index 0000000000..b69f2e8fd3 --- /dev/null +++ b/types/jsontoxml/tsconfig.json @@ -0,0 +1,24 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "esModuleInterop": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "jsontoxml-tests.ts" + ] +} diff --git a/types/jsontoxml/tslint.json b/types/jsontoxml/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/jsontoxml/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" }