From adaacd1077cdf4a8790d14d0fce9f991076f5ee0 Mon Sep 17 00:00:00 2001 From: Jon Surrell Date: Thu, 5 Mar 2020 22:57:15 +0100 Subject: [PATCH] Add html-entities --- packages/html-entities/package.json | 1 + packages/html-entities/src/index.js | 4 +++- packages/html-entities/tsconfig.json | 8 ++++++++ tsconfig.json | 1 + 4 files changed, 13 insertions(+), 1 deletion(-) create mode 100644 packages/html-entities/tsconfig.json diff --git a/packages/html-entities/package.json b/packages/html-entities/package.json index 5e0cb8c0f1d04..f3df5c2856ffa 100644 --- a/packages/html-entities/package.json +++ b/packages/html-entities/package.json @@ -21,6 +21,7 @@ "main": "build/index.js", "module": "build-module/index.js", "react-native": "src/index", + "types": "build-types", "dependencies": { "@babel/runtime": "^7.8.3" }, diff --git a/packages/html-entities/src/index.js b/packages/html-entities/src/index.js index 615087f992e78..cc9d3c3ae5309 100644 --- a/packages/html-entities/src/index.js +++ b/packages/html-entities/src/index.js @@ -1,3 +1,4 @@ +/** @type {HTMLTextAreaElement} */ let _decodeTextArea; /** @@ -36,5 +37,6 @@ export function decodeEntities( html ) { _decodeTextArea.innerHTML = html; const decoded = _decodeTextArea.textContent; _decodeTextArea.innerHTML = ''; - return decoded; + // Cast to string, HTMLTextElement should always have `string` textContent + return /** @type {string} */ ( decoded ); } diff --git a/packages/html-entities/tsconfig.json b/packages/html-entities/tsconfig.json new file mode 100644 index 0000000000000..3c2c31f506f13 --- /dev/null +++ b/packages/html-entities/tsconfig.json @@ -0,0 +1,8 @@ +{ + "extends": "../../tsconfig.base.json", + "compilerOptions": { + "rootDir": "src", + "declarationDir": "build-types" + }, + "include": [ "src/**/*" ] +} diff --git a/tsconfig.json b/tsconfig.json index c43dbd46f72d3..c44723b21e2f5 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -6,6 +6,7 @@ { "path": "packages/blob" }, { "path": "packages/dom-ready" }, { "path": "packages/escape-html" }, + { "path": "packages/html-entities" }, { "path": "packages/i18n" }, { "path": "packages/is-shallow-equal" }, { "path": "packages/priority-queue" },