Skip to content

Commit

Permalink
Add types for html-to-draftjs (DefinitelyTyped#38592)
Browse files Browse the repository at this point in the history
  • Loading branch information
1cheese authored and uniqueiniquity committed Sep 25, 2019
1 parent 3c9854f commit 05ce01b
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 0 deletions.
9 changes: 9 additions & 0 deletions types/html-to-draftjs/html-to-draftjs-tests.ts
Original file line number Diff line number Diff line change
@@ -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 changes: 17 additions & 0 deletions types/html-to-draftjs/index.d.ts
Original file line number Diff line number Diff line change
@@ -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;
};
24 changes: 24 additions & 0 deletions types/html-to-draftjs/tsconfig.json
Original file line number Diff line number Diff line change
@@ -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"
]
}
1 change: 1 addition & 0 deletions types/html-to-draftjs/tslint.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }

0 comments on commit 05ce01b

Please sign in to comment.