From 216d877abfff7b47eed8116064ff637391e07390 Mon Sep 17 00:00:00 2001 From: Charles Kenney Date: Tue, 14 May 2019 17:55:43 -0400 Subject: [PATCH] add xml-escape typings (#35449) --- types/xml-escape/index.d.ts | 13 +++++++++++++ types/xml-escape/tsconfig.json | 16 ++++++++++++++++ types/xml-escape/tslint.json | 3 +++ types/xml-escape/xml-escape-tests.ts | 20 ++++++++++++++++++++ 4 files changed, 52 insertions(+) create mode 100644 types/xml-escape/index.d.ts create mode 100644 types/xml-escape/tsconfig.json create mode 100644 types/xml-escape/tslint.json create mode 100644 types/xml-escape/xml-escape-tests.ts diff --git a/types/xml-escape/index.d.ts b/types/xml-escape/index.d.ts new file mode 100644 index 0000000000..215e182f99 --- /dev/null +++ b/types/xml-escape/index.d.ts @@ -0,0 +1,13 @@ +// Type definitions for xml-escape 1.1 +// Project: https://github.com/miketheprogrammer/xml-escape +// Definitions by: Charles Kenney +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +/** + * Escape an XML string + * + * @param string String of XML to escape + * @param ignore Characters to ignore + */ +declare function escape(string: string, ignore?: string): string; +export = escape; diff --git a/types/xml-escape/tsconfig.json b/types/xml-escape/tsconfig.json new file mode 100644 index 0000000000..9a05ffa915 --- /dev/null +++ b/types/xml-escape/tsconfig.json @@ -0,0 +1,16 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": ["es6"], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "baseUrl": "../", + "typeRoots": ["../"], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": ["index.d.ts", "xml-escape-tests.ts"] +} diff --git a/types/xml-escape/tslint.json b/types/xml-escape/tslint.json new file mode 100644 index 0000000000..f93cf8562a --- /dev/null +++ b/types/xml-escape/tslint.json @@ -0,0 +1,3 @@ +{ + "extends": "dtslint/dt.json" +} diff --git a/types/xml-escape/xml-escape-tests.ts b/types/xml-escape/xml-escape-tests.ts new file mode 100644 index 0000000000..bff3c743fd --- /dev/null +++ b/types/xml-escape/xml-escape-tests.ts @@ -0,0 +1,20 @@ +/// + +import xmlEscape = require("xml-escape"); + +const xml = ` + + Barack Obama + Joe Biden + Cats + I freakin' love cats!!&! +`; + +const fullEscaped = xmlEscape(xml); // $ExpectType string +const preservingApostrophe = xmlEscape(xml, "&"); // $ExpectType string + +console.info({ + fullEscaped, + preservingApostrophe +});