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
This commit is contained in:
Ivan Zverev
2019-09-26 16:09:04 -07:00
committed by Ben Lichtman
parent a9c67da719
commit 99078a21ed
4 changed files with 71 additions and 0 deletions
@@ -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);
+21
View File
@@ -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 <https://github.com/1cheese>
// 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;
+26
View File
@@ -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"
]
}
+3
View File
@@ -0,0 +1,3 @@
{
"extends": "dtslint/dt.json"
}