File tree Expand file tree Collapse file tree 5 files changed +89
-3
lines changed Expand file tree Collapse file tree 5 files changed +89
-3
lines changed Original file line number Diff line number Diff line change 2727 " Titus Wormer <tituswormer@gmail.com> (https://wooorm.com)"
2828 ],
2929 "files" : [
30- " index.js"
30+ " index.js" ,
31+ " types/index.d.ts"
3132 ],
33+ "types" : " types" ,
3234 "dependencies" : {
35+ "@types/mdast" : " ^3.0.0" ,
3336 "mdast-util-to-string" : " ^1.0.0" ,
34- "micromark" : " ~2.9 .0" ,
37+ "micromark" : " ~2.10 .0" ,
3538 "parse-entities" : " ^2.0.0"
3639 },
3740 "devDependencies" : {
3841 "browserify" : " ^16.0.0" ,
3942 "commonmark.json" : " ^0.29.0" ,
43+ "dtslint" : " ^4.0.0" ,
4044 "gzip-size-cli" : " ^3.0.0" ,
4145 "hast-util-to-html" : " ^7.0.0" ,
4246 "mdast-util-to-hast" : " ^10.0.0" ,
5761 "generate" : " npm run generate-size" ,
5862 "test-api" : " node test" ,
5963 "test-coverage" : " nyc --reporter lcov tape test/index.js" ,
60- "test" : " npm run format && npm run generate && npm run test-coverage"
64+ "test-types" : " dtslint types" ,
65+ "test" : " npm run format && npm run generate && npm run test-coverage && npm run test-types"
6166 },
6267 "nyc" : {
6368 "check-coverage" : true ,
Original file line number Diff line number Diff line change 1+ // Minimum TypeScript Version: 3.0
2+ import {
3+ Buffer ,
4+ BufferEncoding ,
5+ SyntaxExtension ,
6+ Token
7+ } from 'micromark/dist/shared-types'
8+ import { Root } from 'mdast'
9+ import { Type } from 'micromark/dist/constant/types'
10+
11+ export = fromMarkdown
12+
13+ declare namespace fromMarkdown {
14+ interface MdastExtension {
15+ enter : Record < Type , ( token : Token ) => void >
16+ exit : Record < Type , ( token : Token ) => void >
17+ }
18+
19+ interface Options {
20+ extensions ?: SyntaxExtension [ ]
21+ mdastExtensions ?: MdastExtension [ ]
22+ }
23+ }
24+
25+ declare function fromMarkdown (
26+ value : string | Buffer ,
27+ options ?: fromMarkdown . Options
28+ ) : Root
29+
30+ declare function fromMarkdown (
31+ value : string | Buffer ,
32+ encoding ?: BufferEncoding ,
33+ options ?: fromMarkdown . Options
34+ ) : Root
Original file line number Diff line number Diff line change 1+ // This file is for https://github.com/microsoft/dtslint .
2+ // Tests are type-checked, but not run.
3+
4+ import * as fromMarkdown from 'mdast-util-from-markdown'
5+
6+ function main ( ) {
7+ const raw = '# text **strong**'
8+
9+ // $ExpectType Root
10+ fromMarkdown ( raw )
11+
12+ // $ExpectType Root
13+ fromMarkdown ( Buffer . alloc ( 8 ) )
14+
15+ // $ExpectType Root
16+ fromMarkdown ( Buffer . alloc ( 8 ) , { extensions : [ ] } )
17+
18+ // $ExpectType Root
19+ fromMarkdown ( Buffer . alloc ( 8 ) , 'utf-8' , { mdastExtensions : [ ] } )
20+
21+ // $ExpectError
22+ fromMarkdown ( Buffer . alloc ( 8 ) , 'utf-8' , { allowDangerousHtml : true } )
23+ }
24+
25+ main ( )
Original file line number Diff line number Diff line change 1+ {
2+ "compilerOptions" : {
3+ "moduleResolution" : " node" ,
4+ "lib" : [
5+ " ES5"
6+ ],
7+ "strict" : true ,
8+ "baseUrl" : " ." ,
9+ "paths" : {
10+ "mdast-util-from-markdown" : [
11+ " ./index.d.ts"
12+ ]
13+ }
14+ }
15+ }
Original file line number Diff line number Diff line change 1+ {
2+ "extends" : " dtslint/dtslint.json" ,
3+ "rules" : {
4+ "semicolon" : false ,
5+ "whitespace" : false
6+ }
7+ }
You can’t perform that action at this time.
0 commit comments