Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(mdx): add additional typings to mdx api #1211

Merged
merged 4 commits into from
Aug 3, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions packages/mdx/types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,19 @@ declare namespace mdx {
*/
footnotes?: boolean

/**
* skip the addition of 'export default' statement when serializing
* to JSX
* @default false
*/
skipExport?: boolean

/**
* wrap 'export default' statement with provided string when serializing
* to JSX
*/
wrapExport?: string

/**
* remark plugins to transform markdown content
*
Expand Down
7 changes: 6 additions & 1 deletion packages/mdx/types/mdx-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,25 @@ import * as mdx from '@mdx-js/mdx'
mdx('# title') // $ExpectType Promise<string>
mdx('# title', {}) // $ExpectType Promise<string>
mdx('# title', {footnotes: false}) // $ExpectType Promise<string>
mdx('# title', {skipExport: false}) // $ExpectType Promise<string>
mdx('# title', {wrapExport: 'React.memo'}) // $ExpectType Promise<string>
mdx('# title', {rehypePlugins: [() => () => ({type: 'test'})]}) // $ExpectType Promise<string>
mdx('# title', {remarkPlugins: [() => () => ({type: 'test'})]}) // $ExpectType Promise<string>
mdx('# title', {compilers: []}) // $ExpectType Promise<string>

mdx.sync('# title') // $ExpectType string
mdx.sync('# title', {}) // $ExpectType string
mdx.sync('# title', {footnotes: false}) // $ExpectType string
mdx.sync('# title', {skipExport: false}) // $ExpectType string
mdx.sync('# title', {wrapExport: 'React.memo'}) // $ExpectType string
mdx.sync('# title', {rehypePlugins: [() => () => ({type: 'test'})]}) // $ExpectType string
mdx.sync('# title', {remarkPlugins: [() => () => ({type: 'test'})]}) // $ExpectType string
mdx.sync('# title', {compilers: []}) // $ExpectType string

mdx.createMdxAstCompiler() // $ExpectType Processor<Settings>
mdx.createMdxAstCompiler({}) // $ExpectType Processor<Settings>
mdx.createMdxAstCompiler({footnotes: false}) // $ExpectType Processor<Settings>
mdx.createMdxAstCompiler({skipExport: false}) // $ExpectType Processor<Settings>
mdx.createMdxAstCompiler({wrapExport: 'React.memo'}) // $ExpectType Processor<Settings>
mdx.createMdxAstCompiler({rehypePlugins: [() => () => ({type: 'test'})]}) // $ExpectType Processor<Settings>
mdx.createMdxAstCompiler({remarkPlugins: [() => () => ({type: 'test'})]}) // $ExpectType Processor<Settings>
mdx.createMdxAstCompiler({compilers: []}) // $ExpectType Processor<Settings>