Add types for html-to-draftjs (#38592)

This commit is contained in:
Ivan Zverev 2019-09-25 19:59:39 +03:00 committed by Ben Lichtman
parent 3c9854f984
commit 05ce01bbe4
4 changed files with 51 additions and 0 deletions

View File

@ -0,0 +1,9 @@
import htmlToDraft from 'html-to-draftjs';
import { ContentBlock } from 'draft-js';
const blocksFromHtml = htmlToDraft('<p>test</p>');
// $ExpectType ContentBlock[]
const contentBlocks = blocksFromHtml.contentBlocks;
// $ExpectType any
const entityMap = blocksFromHtml.entityMap;

17
types/html-to-draftjs/index.d.ts vendored Normal file
View File

@ -0,0 +1,17 @@
// Type definitions for html-to-draftjs 1.4
// Project: https://github.com/jpuri/html-to-draftjs#readme
// Definitions by: Ivan Zverev <https://github.com/1cheese>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.9
import { ContentBlock, RawDraftEntity } from 'draft-js';
export default function htmlToDraft(
text: string,
customChunkRenderer?: (
nodeName: string, node: HTMLElement
) => RawDraftEntity | undefined,
): {
contentBlocks: ContentBlock[];
entityMap?: any;
};

View File

@ -0,0 +1,24 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6",
"dom"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictFunctionTypes": true,
"strictNullChecks": true,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"html-to-draftjs-tests.ts"
]
}

View File

@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }