# Default CJS exports This document will cover all the types of default exports that can be generated by [rollup-plugin-dts](https://github.com/Swatinem/rollup-plugin-dts) plugin. ### Export default without specifier from the module itself The following example can be found in the [reexport-types](test/fixtures/reexport-types) fixture, check `index.ts` module. Given the following code: ```ts // module.ts export default function foo() {} ``` `rollup-plugin-dts` will generate: ```ts // module.d.[c]ts declare function foo(): void export { foo as default } ``` we need to convert it to: ```ts // module.d.[c]ts declare function foo(): void export = foo ``` ### Exporting default from default import The following example can be found in the [reexport-default](test/fixtures/reexport-default) fixture, check `index.ts` module. Given the following code: ```ts // module.ts import MagicString from 'magic-string' export default MagicString ``` `rollup-plugin-dts` will generate: ```ts // module.d.[c]ts import MagicString from 'magic-string' export { default } from 'magic-string' ``` we need to convert it to (doesn't require adding the import): ```ts // module.d.[c]ts import MagicString from 'magic-string' export = MagicString ``` ### Exporting default with specifier The following example can be found in the [reexport-types](test/fixtures/reexport-types) fixture, check `all.ts` module. Given the following code: ```ts // module.ts export type * from './index.ts' export { default } from './index.ts' ``` `rollup-plugin-dts` will generate: ```ts // module.d.[c]ts // otherexports and otherexporttypes when present export { default, otherexports, type otherexporttypes } from './index.js' ``` we need to convert it to (requires adding the import): ```ts // module.d.[c]ts import _default from './index.js' export = _default // otherexports and otherexporttypes when present export { otherexports, type otherexporttypes } from './index.js' ``` ### Exporting default from named import as default export with specifier The following example can be found in the [reexport-default](test/fixtures/reexport-default) fixture, check `asdefault.ts` module. Given the following code: ```ts // module.ts import { resolve } from 'pathe' export default resolve ``` `rollup-plugin-dts` will generate: ```ts // module.d.[c]ts import { resolve } from 'pathe' export { resolve as default } from 'pathe' ``` we need to convert it to (doesn't require adding the import): ```ts // module.d.[c]ts import { resolve } from 'pathe' export = resolve ``` ### Exporting named export as default with specifier The following example can be found in the [reexport-default](test/fixtures/reexport-default) fixture, check `resolveasdefault.ts` module. Given the following code: ```ts // module.ts export { resolve as default } from 'pathe' ``` `rollup-plugin-dts` will generate: ```ts // module.d.[c]ts export { resolve as default } from 'pathe' ``` we need to convert it to (requires adding the import): ```ts // module.d.[c]ts import { resolve } from 'pathe' export = resolve ```