From 99078a21ed426a1127fc6cbd1e4a3510258490e5 Mon Sep 17 00:00:00 2001 From: Ivan Zverev <35346537+1cheese@users.noreply.github.com> Date: Fri, 27 Sep 2019 02:09:04 +0300 Subject: [PATCH] Add types for draftjs-to-html (#38588) * Add types for draftjs-to-html * Add types for draftjs-to-html: remove excess blank line * Add types for draftjs-to-html: change function export --- .../draftjs-to-html/draftjs-to-html-tests.ts | 21 +++++++++++++++ types/draftjs-to-html/index.d.ts | 21 +++++++++++++++ types/draftjs-to-html/tsconfig.json | 26 +++++++++++++++++++ types/draftjs-to-html/tslint.json | 3 +++ 4 files changed, 71 insertions(+) create mode 100644 types/draftjs-to-html/draftjs-to-html-tests.ts create mode 100644 types/draftjs-to-html/index.d.ts create mode 100644 types/draftjs-to-html/tsconfig.json create mode 100644 types/draftjs-to-html/tslint.json diff --git a/types/draftjs-to-html/draftjs-to-html-tests.ts b/types/draftjs-to-html/draftjs-to-html-tests.ts new file mode 100644 index 0000000000..579e8f9138 --- /dev/null +++ b/types/draftjs-to-html/draftjs-to-html-tests.ts @@ -0,0 +1,21 @@ +import draftToHtml from 'draftjs-to-html'; + +const editorContent = { + blocks: [ + { + key: '355iu', + text: 'test', + type: 'unstyled', + depth: 0, + inlineStyleRanges: [], + entityRanges: [], + data: { + 'text-align': 'center', + }, + }, + ], + entityMap: {}, +}; + +// $ExpectType string +draftToHtml(editorContent); diff --git a/types/draftjs-to-html/index.d.ts b/types/draftjs-to-html/index.d.ts new file mode 100644 index 0000000000..fd5b6e8f30 --- /dev/null +++ b/types/draftjs-to-html/index.d.ts @@ -0,0 +1,21 @@ +// Type definitions for draftjs-to-html 0.8 +// Project: https://github.com/jpuri/draftjs-to-html#readme +// Definitions by: Ivan Zverev +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.9 + +import { RawDraftContentState } from 'draft-js'; + +interface HashtagConfig { + trigger?: string; + separator?: string; +} + +declare function draftToHtml( + editorContent: RawDraftContentState, + hashtagConfig?: HashtagConfig, + directional?: boolean, + customEntityTransform?: (...args: any[]) => any, +): string; + +export = draftToHtml; diff --git a/types/draftjs-to-html/tsconfig.json b/types/draftjs-to-html/tsconfig.json new file mode 100644 index 0000000000..3cc389a199 --- /dev/null +++ b/types/draftjs-to-html/tsconfig.json @@ -0,0 +1,26 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6", + "dom" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "baseUrl": "../", + "jsx": "react", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true, + "esModuleInterop": true + }, + "files": [ + "index.d.ts", + "draftjs-to-html-tests.ts" + ] +} diff --git a/types/draftjs-to-html/tslint.json b/types/draftjs-to-html/tslint.json new file mode 100644 index 0000000000..f93cf8562a --- /dev/null +++ b/types/draftjs-to-html/tslint.json @@ -0,0 +1,3 @@ +{ + "extends": "dtslint/dt.json" +}