diff --git a/CHANGELOG.md b/CHANGELOG.md index a197c22..098a34a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # dts-buddy changelog +## 0.5.1 + +- Use more TypeScript-friendly way of preventing unintended exports ([#85](https://github.com/Rich-Harris/dts-buddy/pull/85)) + ## 0.5.0 - Prevent unintended exports ([#82](https://github.com/Rich-Harris/dts-buddy/pull/82)) diff --git a/src/create-module-declaration.js b/src/create-module-declaration.js index 9538e4f..c0e8144 100644 --- a/src/create-module-declaration.js +++ b/src/create-module-declaration.js @@ -167,9 +167,11 @@ export function create_module_declaration(id, entry, created, resolve) { declaration.alias = get_name(globals.has(name) ? declaration.name : name); mark(declaration); - export_specifiers.push( - declaration.alias === name ? name : `${declaration.alias} as ${name}` - ); + if (declaration.alias !== name) { + export_specifiers.push(`${declaration.alias} as ${name}`); + } else { + declaration.exported = true; + } } else { throw new Error('Something strange happened'); } @@ -323,10 +325,15 @@ export function create_module_declaration(id, entry, created, resolve) { } } - let b = export_modifier.end; - const a = b - 6; - while (/\s/.test(module.dts[b])) b += 1; - result.remove(a, b); + if (!exports.has(declaration.alias)) { + // remove all export keywords in the initial pass; reinstate as necessary later + let b = export_modifier.end; + const a = b - 6; + while (/\s/.test(module.dts[b])) b += 1; + result.remove(a, b); + } + } else if (declaration.exported) { + export_specifiers.push(declaration.alias); } } @@ -391,24 +398,22 @@ export function create_module_declaration(id, entry, created, resolve) { if (mod) content += '\n' + mod; } - if (export_specifiers.length > 0) { - content += `\n\n\texport { ${export_specifiers.join(', ')} };`; - } - // finally, export any bindings that are exported from external modules - /** @type {string[]} */ - const specifiers = []; - for (const name of exports) { const declaration = trace_export(entry, name); if (declaration?.external) { - specifiers.push(declaration.alias); + export_specifiers.push(declaration.alias); } } - if (specifiers.length > 0) { - content += `\n\texport { ${specifiers.join(', ')} };`; + // Always add an export { .. } statement, even if there are no exports. This ensures + // that only the public types are exposed to consumers of the declaration file. Due to some + // old TypeScript inconsistency, omitting the export statement would expose all types. + if (export_specifiers.length > 0) { + content += `\n\n\texport { ${export_specifiers.join(', ')} };`; + } else { + content += '\n\n\texport {};'; } content += `\n}`; @@ -500,6 +505,7 @@ export function create_module_declaration(id, entry, created, resolve) { module: '', external: false, included: true, + exported: false, name, alias: name, dependencies: [], @@ -527,6 +533,7 @@ function create_external_declaration(binding, alias) { module: binding.id, name: binding.name, alias: '', + exported: false, external: true, included: false, dependencies: [], diff --git a/src/types.d.ts b/src/types.d.ts index 398d424..ab4a6c2 100644 --- a/src/types.d.ts +++ b/src/types.d.ts @@ -11,6 +11,7 @@ interface Declaration { module: string; name: string; alias: string; + exported: boolean; external: boolean; included: boolean; dependencies: Reference[]; diff --git a/src/utils.js b/src/utils.js index 0582b9a..4c257fa 100644 --- a/src/utils.js +++ b/src/utils.js @@ -342,6 +342,7 @@ export function get_dts(file, created, resolve) { module: file, name, alias: '', + exported: false, included: false, external: false, dependencies: [], diff --git a/test/samples/ambient-imports/output/index.d.ts b/test/samples/ambient-imports/output/index.d.ts index f738c97..2db6981 100644 --- a/test/samples/ambient-imports/output/index.d.ts +++ b/test/samples/ambient-imports/output/index.d.ts @@ -1,9 +1,9 @@ /// declare module 'ambient-imports' { - interface Foo {} + export interface Foo {} - export { Foo }; + export {}; } //# sourceMappingURL=index.d.ts.map \ No newline at end of file diff --git a/test/samples/ambient-imports/output/index.d.ts.map b/test/samples/ambient-imports/output/index.d.ts.map index 6c8a32c..ff6baf1 100644 --- a/test/samples/ambient-imports/output/index.d.ts.map +++ b/test/samples/ambient-imports/output/index.d.ts.map @@ -10,5 +10,5 @@ "sourcesContent": [ null ], - "mappings": ";;;WAEiBA,GAAGA" + "mappings": ";;;kBAEiBA,GAAGA" } \ No newline at end of file diff --git a/test/samples/basic/output 5.5/index.d.ts b/test/samples/basic/output 5.5/index.d.ts index 68a43e3..741d233 100644 --- a/test/samples/basic/output 5.5/index.d.ts +++ b/test/samples/basic/output 5.5/index.d.ts @@ -1,6 +1,6 @@ declare module 'basic' { /** A vector with two components */ - interface Vector2 { + export interface Vector2 { /** The x component */ x: number; /** The y component */ @@ -11,18 +11,18 @@ declare module 'basic' { * @param a the first vector * @param b the second vector * */ - function add(a: Vector2, b: Vector2): Vector2; + export function add(a: Vector2, b: Vector2): Vector2; - export { Vector2, add }; + export {}; } declare module 'basic/subpackage' { /** * Multiply two vectors * */ - function multiply(a: import("basic").Vector2, b: import("basic").Vector2): import("basic").Vector2; + export function multiply(a: import("basic").Vector2, b: import("basic").Vector2): import("basic").Vector2; - export { multiply }; + export {}; } -//# sourceMappingURL=index.d.ts.map +//# sourceMappingURL=index.d.ts.map \ No newline at end of file diff --git a/test/samples/basic/output 5.5/index.d.ts.map b/test/samples/basic/output 5.5/index.d.ts.map index 3e724d7..6688801 100644 --- a/test/samples/basic/output 5.5/index.d.ts.map +++ b/test/samples/basic/output 5.5/index.d.ts.map @@ -16,5 +16,5 @@ null, null ], - "mappings": ";;WACiBA,OAAOA;;;;;;;;;;;UCKRC,GAAGA;;;;;;;;;UCAHC,QAAQA" -} + "mappings": ";;kBACiBA,OAAOA;;;;;;;;;;;iBCKRC,GAAGA;;;;;;;;;iBCAHC,QAAQA" +} \ No newline at end of file diff --git a/test/samples/basic/output/index.d.ts b/test/samples/basic/output/index.d.ts index 743d48d..74ed6a6 100644 --- a/test/samples/basic/output/index.d.ts +++ b/test/samples/basic/output/index.d.ts @@ -1,6 +1,6 @@ declare module 'basic' { /** A vector with two components */ - interface Vector2 { + export interface Vector2 { /** The x component */ x: number; /** The y component */ @@ -11,18 +11,18 @@ declare module 'basic' { * @param a the first vector * @param b the second vector * */ - function add(a: Vector2, b: Vector2): Vector2; + export function add(a: Vector2, b: Vector2): Vector2; - export { Vector2, add }; + export {}; } declare module 'basic/subpackage' { /** * Multiply two vectors * */ - function multiply(a: import('basic').Vector2, b: import('basic').Vector2): import('basic').Vector2; + export function multiply(a: import('basic').Vector2, b: import('basic').Vector2): import('basic').Vector2; - export { multiply }; + export {}; } -//# sourceMappingURL=index.d.ts.map +//# sourceMappingURL=index.d.ts.map \ No newline at end of file diff --git a/test/samples/basic/output/index.d.ts.map b/test/samples/basic/output/index.d.ts.map index 1cfa890..6688801 100644 --- a/test/samples/basic/output/index.d.ts.map +++ b/test/samples/basic/output/index.d.ts.map @@ -16,5 +16,5 @@ null, null ], - "mappings": ";;WACiBA,OAAOA;;;;;;;;;;;UCKRC,GAAGA;;;;;;;;;UCAHC,QAAQA" + "mappings": ";;kBACiBA,OAAOA;;;;;;;;;;;iBCKRC,GAAGA;;;;;;;;;iBCAHC,QAAQA" } \ No newline at end of file diff --git a/test/samples/const-namespace/output 5.0/index.d.ts b/test/samples/const-namespace/output 5.0/index.d.ts index ebb55cc..e751cb3 100644 --- a/test/samples/const-namespace/output 5.0/index.d.ts +++ b/test/samples/const-namespace/output 5.0/index.d.ts @@ -1,9 +1,9 @@ declare module 'const-namespace' { - namespace a { + export namespace a { const x: number; } - export { a }; + export {}; } -//# sourceMappingURL=index.d.ts.map +//# sourceMappingURL=index.d.ts.map \ No newline at end of file diff --git a/test/samples/const-namespace/output/index.d.ts b/test/samples/const-namespace/output/index.d.ts index 42c5af2..385986d 100644 --- a/test/samples/const-namespace/output/index.d.ts +++ b/test/samples/const-namespace/output/index.d.ts @@ -1,9 +1,9 @@ declare module 'const-namespace' { - namespace a { + export namespace a { let x: number; } - export { a }; + export {}; } //# sourceMappingURL=index.d.ts.map \ No newline at end of file diff --git a/test/samples/declare-module/output/index.d.ts b/test/samples/declare-module/output/index.d.ts index 409ee5a..990fe28 100644 --- a/test/samples/declare-module/output/index.d.ts +++ b/test/samples/declare-module/output/index.d.ts @@ -1,7 +1,7 @@ declare module 'declare-module' { - interface Foo {} + export interface Foo {} - export { Foo }; + export {}; } //# sourceMappingURL=index.d.ts.map \ No newline at end of file diff --git a/test/samples/declare-module/output/index.d.ts.map b/test/samples/declare-module/output/index.d.ts.map index 490a511..5e02c16 100644 --- a/test/samples/declare-module/output/index.d.ts.map +++ b/test/samples/declare-module/output/index.d.ts.map @@ -10,5 +10,5 @@ "sourcesContent": [ null ], - "mappings": ";WAOiBA,GAAGA" + "mappings": ";kBAOiBA,GAAGA" } \ No newline at end of file diff --git a/test/samples/deconflict-priority/output/index.d.ts b/test/samples/deconflict-priority/output/index.d.ts index fd7e0e3..e631e80 100644 --- a/test/samples/deconflict-priority/output/index.d.ts +++ b/test/samples/deconflict-priority/output/index.d.ts @@ -1,9 +1,9 @@ declare module 'deconflict-priority' { - function x(foo: Foo, bar: Bar): void; + export function x(foo: Foo, bar: Bar): void; interface Foo {} interface Bar {} - export { x }; + export {}; } //# sourceMappingURL=index.d.ts.map \ No newline at end of file diff --git a/test/samples/deconflict-priority/output/index.d.ts.map b/test/samples/deconflict-priority/output/index.d.ts.map index 8d95e46..cd3dac6 100644 --- a/test/samples/deconflict-priority/output/index.d.ts.map +++ b/test/samples/deconflict-priority/output/index.d.ts.map @@ -16,5 +16,5 @@ null, null ], - "mappings": ";UAIgBA,CAACA;WCJAC,GAAGA;WCCHC,GAAGA" + "mappings": ";iBAIgBA,CAACA;WCJAC,GAAGA;WCCHC,GAAGA" } \ No newline at end of file diff --git a/test/samples/enum/output/index.d.ts b/test/samples/enum/output/index.d.ts index 5dbd302..1e199cc 100644 --- a/test/samples/enum/output/index.d.ts +++ b/test/samples/enum/output/index.d.ts @@ -1,11 +1,11 @@ declare module 'enum' { - enum categories { + export enum categories { ANIMAL = 0, VEGETABLE = 1, MINERAL = 2 } - export { categories }; + export {}; } //# sourceMappingURL=index.d.ts.map \ No newline at end of file diff --git a/test/samples/enum/output/index.d.ts.map b/test/samples/enum/output/index.d.ts.map index 3c3a945..e8a9023 100644 --- a/test/samples/enum/output/index.d.ts.map +++ b/test/samples/enum/output/index.d.ts.map @@ -10,5 +10,5 @@ "sourcesContent": [ null ], - "mappings": ";MAAYA,UAAUA" -} \ No newline at end of file + "mappings": ";aAAYA,UAAUA" +} diff --git a/test/samples/export-default-as/output/index.d.ts b/test/samples/export-default-as/output/index.d.ts index 9e62f4e..dae8af7 100644 --- a/test/samples/export-default-as/output/index.d.ts +++ b/test/samples/export-default-as/output/index.d.ts @@ -2,9 +2,9 @@ declare module 'export-default-as' { /** * Add two numbers * */ - function add(a: number, b: number): number; + export function add(a: number, b: number): number; - export { add }; + export {}; } //# sourceMappingURL=index.d.ts.map \ No newline at end of file diff --git a/test/samples/export-default-as/output/index.d.ts.map b/test/samples/export-default-as/output/index.d.ts.map index 4101c9d..975a5d5 100644 --- a/test/samples/export-default-as/output/index.d.ts.map +++ b/test/samples/export-default-as/output/index.d.ts.map @@ -10,5 +10,5 @@ "sourcesContent": [ null ], - "mappings": ";;;;UAMwBA,GAAGA" + "mappings": ";;;;iBAMwBA,GAAGA" } \ No newline at end of file diff --git a/test/samples/export-default-function/output/index.d.ts b/test/samples/export-default-function/output/index.d.ts index 31e690f..bd83584 100644 --- a/test/samples/export-default-function/output/index.d.ts +++ b/test/samples/export-default-function/output/index.d.ts @@ -1,7 +1,7 @@ declare module 'export-default-function' { export default function foo(): void; - export { default }; + export {}; } //# sourceMappingURL=index.d.ts.map \ No newline at end of file diff --git a/test/samples/export-default-value/output/index.d.ts b/test/samples/export-default-value/output/index.d.ts index f4ed322..ea47de0 100644 --- a/test/samples/export-default-value/output/index.d.ts +++ b/test/samples/export-default-value/output/index.d.ts @@ -2,7 +2,7 @@ declare module 'export-default-value' { const _default: 42; export default _default; - export { default }; + export {}; } //# sourceMappingURL=index.d.ts.map \ No newline at end of file diff --git a/test/samples/export-from/output/index.d.ts b/test/samples/export-from/output/index.d.ts index 4da8f13..03aca78 100644 --- a/test/samples/export-from/output/index.d.ts +++ b/test/samples/export-from/output/index.d.ts @@ -1,7 +1,7 @@ declare module 'export-from' { - const foo: "hello"; + export const foo: "hello"; - export { foo }; + export {}; } //# sourceMappingURL=index.d.ts.map \ No newline at end of file diff --git a/test/samples/export-from/output/index.d.ts.map b/test/samples/export-from/output/index.d.ts.map index fd32c89..d556af0 100644 --- a/test/samples/export-from/output/index.d.ts.map +++ b/test/samples/export-from/output/index.d.ts.map @@ -10,5 +10,5 @@ "sourcesContent": [ null ], - "mappings": ";OAAaA,GAAGA" + "mappings": ";cAAaA,GAAGA" } \ No newline at end of file diff --git a/test/samples/export-named-as/output/index.d.ts b/test/samples/export-named-as/output/index.d.ts index 59382a7..2de976f 100644 --- a/test/samples/export-named-as/output/index.d.ts +++ b/test/samples/export-named-as/output/index.d.ts @@ -2,9 +2,9 @@ declare module 'export-named-as' { /** * Add two numbers * */ - function plus(a: number, b: number): number; + export function plus(a: number, b: number): number; - export { plus }; + export {}; } //# sourceMappingURL=index.d.ts.map \ No newline at end of file diff --git a/test/samples/export-type/output/index.d.ts b/test/samples/export-type/output/index.d.ts index 6f3431e..87b8ce4 100644 --- a/test/samples/export-type/output/index.d.ts +++ b/test/samples/export-type/output/index.d.ts @@ -1,8 +1,8 @@ declare module 'export-type' { - type D = {}; - class B {} + export type D = {}; + export class B {} - export { B, D }; + export {}; } //# sourceMappingURL=index.d.ts.map \ No newline at end of file diff --git a/test/samples/export-type/output/index.d.ts.map b/test/samples/export-type/output/index.d.ts.map index c6b7375..2fd1ead 100644 --- a/test/samples/export-type/output/index.d.ts.map +++ b/test/samples/export-type/output/index.d.ts.map @@ -5,4 +5,4 @@ "sources": [], "sourcesContent": [], "mappings": "" -} \ No newline at end of file +} diff --git a/test/samples/generics/output/index.d.ts b/test/samples/generics/output/index.d.ts index 586a9dc..fafa0aa 100644 --- a/test/samples/generics/output/index.d.ts +++ b/test/samples/generics/output/index.d.ts @@ -1,9 +1,9 @@ declare module 'generics' { - interface Foo { + export interface Foo { bar: T; } - export { Foo }; + export {}; } //# sourceMappingURL=index.d.ts.map \ No newline at end of file diff --git a/test/samples/generics/output/index.d.ts.map b/test/samples/generics/output/index.d.ts.map index 0099d44..8e32b8b 100644 --- a/test/samples/generics/output/index.d.ts.map +++ b/test/samples/generics/output/index.d.ts.map @@ -10,5 +10,5 @@ "sourcesContent": [ null ], - "mappings": ";WAAiBA,GAAGA" + "mappings": ";kBAAiBA,GAAGA" } \ No newline at end of file diff --git a/test/samples/ignores-missing-sourcemap-segments/output 5.0/index.d.ts b/test/samples/ignores-missing-sourcemap-segments/output 5.0/index.d.ts index 9677ab3..f728c40 100644 --- a/test/samples/ignores-missing-sourcemap-segments/output 5.0/index.d.ts +++ b/test/samples/ignores-missing-sourcemap-segments/output 5.0/index.d.ts @@ -1,10 +1,10 @@ declare module 'ignores-missing-sourcemap-segments' { - function hello(): void; - namespace object { + export function hello(): void; + export namespace object { const answer: number; } - export { hello, object }; + export {}; } -//# sourceMappingURL=index.d.ts.map +//# sourceMappingURL=index.d.ts.map \ No newline at end of file diff --git a/test/samples/ignores-missing-sourcemap-segments/output 5.0/index.d.ts.map b/test/samples/ignores-missing-sourcemap-segments/output 5.0/index.d.ts.map index f5773e6..e1bbe17 100644 --- a/test/samples/ignores-missing-sourcemap-segments/output 5.0/index.d.ts.map +++ b/test/samples/ignores-missing-sourcemap-segments/output 5.0/index.d.ts.map @@ -13,5 +13,5 @@ null, null ], - "mappings": ";UAIgBA,KAAKA;WCHJC,MAAMA" -} + "mappings": ";iBAIgBA,KAAKA;kBCHJC,MAAMA" +} \ No newline at end of file diff --git a/test/samples/ignores-missing-sourcemap-segments/output/index.d.ts b/test/samples/ignores-missing-sourcemap-segments/output/index.d.ts index 3868210..28811c5 100644 --- a/test/samples/ignores-missing-sourcemap-segments/output/index.d.ts +++ b/test/samples/ignores-missing-sourcemap-segments/output/index.d.ts @@ -1,10 +1,10 @@ declare module 'ignores-missing-sourcemap-segments' { - function hello(): void; - namespace object { + export function hello(): void; + export namespace object { let answer: number; } - export { hello, object }; + export {}; } //# sourceMappingURL=index.d.ts.map \ No newline at end of file diff --git a/test/samples/ignores-missing-sourcemap-segments/output/index.d.ts.map b/test/samples/ignores-missing-sourcemap-segments/output/index.d.ts.map index f11f04f..e1bbe17 100644 --- a/test/samples/ignores-missing-sourcemap-segments/output/index.d.ts.map +++ b/test/samples/ignores-missing-sourcemap-segments/output/index.d.ts.map @@ -13,5 +13,5 @@ null, null ], - "mappings": ";UAIgBA,KAAKA;WCHJC,MAAMA" + "mappings": ";iBAIgBA,KAAKA;kBCHJC,MAAMA" } \ No newline at end of file diff --git a/test/samples/import-external-default/output/index.d.ts b/test/samples/import-external-default/output/index.d.ts index 639ec5d..403895b 100644 --- a/test/samples/import-external-default/output/index.d.ts +++ b/test/samples/import-external-default/output/index.d.ts @@ -1,8 +1,8 @@ declare module 'import-external-default' { import type { default as x } from 'external'; - function foo(input: x): x; + export function foo(input: x): x; - export { foo }; + export {}; } //# sourceMappingURL=index.d.ts.map \ No newline at end of file diff --git a/test/samples/import-external-default/output/index.d.ts.map b/test/samples/import-external-default/output/index.d.ts.map index 9e59a8e..4c842cb 100644 --- a/test/samples/import-external-default/output/index.d.ts.map +++ b/test/samples/import-external-default/output/index.d.ts.map @@ -10,5 +10,5 @@ "sourcesContent": [ null ], - "mappings": ";;UAEgBA,GAAGA" -} \ No newline at end of file + "mappings": ";;iBAEgBA,GAAGA" +} diff --git a/test/samples/import-external-named-as-conflict/output/index.d.ts b/test/samples/import-external-named-as-conflict/output/index.d.ts index c30f8a0..5a1af1f 100644 --- a/test/samples/import-external-named-as-conflict/output/index.d.ts +++ b/test/samples/import-external-named-as-conflict/output/index.d.ts @@ -1,8 +1,7 @@ declare module 'import-external-named-as-conflict' { import type { foo as f } from 'external'; - function foo(): void; + export function foo(): void; - export { foo, f }; export { f }; } diff --git a/test/samples/import-external-named-as-conflict/output/index.d.ts.map b/test/samples/import-external-named-as-conflict/output/index.d.ts.map index 7a8aa3a..8813318 100644 --- a/test/samples/import-external-named-as-conflict/output/index.d.ts.map +++ b/test/samples/import-external-named-as-conflict/output/index.d.ts.map @@ -10,5 +10,5 @@ "sourcesContent": [ null ], - "mappings": ";;UAIgBA,GAAGA" -} \ No newline at end of file + "mappings": ";;iBAIgBA,GAAGA" +} diff --git a/test/samples/import-external-named-as/output/index.d.ts b/test/samples/import-external-named-as/output/index.d.ts index 7dedc3d..36cfe5a 100644 --- a/test/samples/import-external-named-as/output/index.d.ts +++ b/test/samples/import-external-named-as/output/index.d.ts @@ -2,7 +2,6 @@ declare module 'import-external-named-as' { import type { foo as f } from 'external'; export { f }; - export { f }; } //# sourceMappingURL=index.d.ts.map \ No newline at end of file diff --git a/test/samples/import-external-named/output/index.d.ts b/test/samples/import-external-named/output/index.d.ts index 1c4a24c..628656c 100644 --- a/test/samples/import-external-named/output/index.d.ts +++ b/test/samples/import-external-named/output/index.d.ts @@ -2,7 +2,6 @@ declare module 'import-external-named' { import type { foo } from 'external'; export { foo }; - export { foo }; } //# sourceMappingURL=index.d.ts.map \ No newline at end of file diff --git a/test/samples/jsdoc-import/output 5.5/index.d.ts b/test/samples/jsdoc-import/output 5.5/index.d.ts index 0894aee..5cfc526 100644 --- a/test/samples/jsdoc-import/output 5.5/index.d.ts +++ b/test/samples/jsdoc-import/output 5.5/index.d.ts @@ -4,7 +4,7 @@ declare module 'jsdoc-import' { * @param a the first vector * @param b the second vector * */ - function add(a: Vector2, b: Vector2): Vector2; + export function add(a: Vector2, b: Vector2): Vector2; /** A vector with two components */ interface Vector2 { /** The x component */ @@ -13,7 +13,7 @@ declare module 'jsdoc-import' { y: number; } - export { add }; + export {}; } -//# sourceMappingURL=index.d.ts.map +//# sourceMappingURL=index.d.ts.map \ No newline at end of file diff --git a/test/samples/jsdoc-import/output 5.5/index.d.ts.map b/test/samples/jsdoc-import/output 5.5/index.d.ts.map index f12e450..6cbc914 100644 --- a/test/samples/jsdoc-import/output 5.5/index.d.ts.map +++ b/test/samples/jsdoc-import/output 5.5/index.d.ts.map @@ -13,5 +13,5 @@ null, null ], - "mappings": ";;;;;;UAQgBA,GAAGA;;WCPFC,OAAOA" -} + "mappings": ";;;;;;iBAQgBA,GAAGA;;WCPFC,OAAOA" +} \ No newline at end of file diff --git a/test/samples/jsdoc-import/output/index.d.ts b/test/samples/jsdoc-import/output/index.d.ts index 9ff9cf7..1370bb3 100644 --- a/test/samples/jsdoc-import/output/index.d.ts +++ b/test/samples/jsdoc-import/output/index.d.ts @@ -5,9 +5,9 @@ declare module 'jsdoc-import' { * @param a the first vector * @param b the second vector * */ - function add(a: Vector2, b: Vector2): Vector2; + export function add(a: Vector2, b: Vector2): Vector2; - export { add }; + export {}; } //# sourceMappingURL=index.d.ts.map \ No newline at end of file diff --git a/test/samples/jsdoc-import/output/index.d.ts.map b/test/samples/jsdoc-import/output/index.d.ts.map index 95b40bc..12863e8 100644 --- a/test/samples/jsdoc-import/output/index.d.ts.map +++ b/test/samples/jsdoc-import/output/index.d.ts.map @@ -10,5 +10,5 @@ "sourcesContent": [ null ], - "mappings": ";;;;;;;UAQgBA,GAAGA" + "mappings": ";;;;;;;iBAQgBA,GAAGA" } \ No newline at end of file diff --git a/test/samples/namespace-exports/output/index.d.ts b/test/samples/namespace-exports/output/index.d.ts index 847fb55..f37960c 100644 --- a/test/samples/namespace-exports/output/index.d.ts +++ b/test/samples/namespace-exports/output/index.d.ts @@ -1,5 +1,5 @@ declare module 'namespace-exports' { - type X = Namespace.X; + export type X = Namespace.X; namespace Namespace { interface X { x: string; @@ -9,7 +9,7 @@ declare module 'namespace-exports' { } } - export { X }; + export {}; } //# sourceMappingURL=index.d.ts.map \ No newline at end of file diff --git a/test/samples/namespace-exports/output/index.d.ts.map b/test/samples/namespace-exports/output/index.d.ts.map index cd6b925..d534ceb 100644 --- a/test/samples/namespace-exports/output/index.d.ts.map +++ b/test/samples/namespace-exports/output/index.d.ts.map @@ -13,5 +13,5 @@ null, null ], - "mappings": ";MAEYA,CAACA;WCFIC,SAASA" -} \ No newline at end of file + "mappings": ";aAEYA,CAACA;WCFIC,SAASA" +} diff --git a/test/samples/overloads/output/index.d.ts b/test/samples/overloads/output/index.d.ts index 0c79519..c229221 100644 --- a/test/samples/overloads/output/index.d.ts +++ b/test/samples/overloads/output/index.d.ts @@ -3,10 +3,10 @@ declare module 'overloads' { } interface Bar { } - function baz(input: Foo): Foo; - function baz(input: Bar): Bar; + export function baz(input: Foo): Foo; + export function baz(input: Bar): Bar; - export { baz }; + export {}; } //# sourceMappingURL=index.d.ts.map \ No newline at end of file diff --git a/test/samples/overloads/output/index.d.ts.map b/test/samples/overloads/output/index.d.ts.map index 47fb239..3a5528d 100644 --- a/test/samples/overloads/output/index.d.ts.map +++ b/test/samples/overloads/output/index.d.ts.map @@ -10,5 +10,5 @@ "sourcesContent": [ null ], - "mappings": ";;;;;UAIgBA,GAAGA;UAAHA,GAAGA" -} \ No newline at end of file + "mappings": ";;;;;iBAIgBA,GAAGA;iBAAHA,GAAGA" +} diff --git a/test/samples/path-config/output 5.0 - 5.1/index.d.ts b/test/samples/path-config/output 5.0 - 5.1/index.d.ts index 0dbc729..7765506 100644 --- a/test/samples/path-config/output 5.0 - 5.1/index.d.ts +++ b/test/samples/path-config/output 5.0 - 5.1/index.d.ts @@ -1,17 +1,17 @@ declare module 'path-config' { - function foo(input: Input): Output; - function overload(input: Input): Output; - function overload(input: string): Output; + export function foo(input: Input): Output; + export function overload(input: Input): Output; + export function overload(input: string): Output; - function foo2(foo: Foo): void; - type Foo = { + export function foo2(foo: Foo): void; + export type Foo = { foo: Input; }; type Input = number; type Output = number; - function foo_nested(input: Input): Output; + export function foo_nested(input: Input): Output; - export { foo, overload, foo2, Foo, foo_nested }; + export {}; } -//# sourceMappingURL=index.d.ts.map +//# sourceMappingURL=index.d.ts.map \ No newline at end of file diff --git a/test/samples/path-config/output 5.0 - 5.1/index.d.ts.map b/test/samples/path-config/output 5.0 - 5.1/index.d.ts.map index 6df81c7..95cd82d 100644 --- a/test/samples/path-config/output 5.0 - 5.1/index.d.ts.map +++ b/test/samples/path-config/output 5.0 - 5.1/index.d.ts.map @@ -19,5 +19,5 @@ null, null ], - "mappings": ";UAMgBA,GAAGA;UASfC,QAAQA;UAARA,QAAQA;;UAgBIC,IAAIA;;;;MC/BRC,KAAKA;MACLC,MAAMA;UCGFC,UAAUA" -} + "mappings": ";iBAMgBA,GAAGA;iBASfC,QAAQA;iBAARA,QAAQA;;iBAgBIC,IAAIA;;;;MC/BRC,KAAKA;MACLC,MAAMA;iBCGFC,UAAUA" +} \ No newline at end of file diff --git a/test/samples/path-config/output/index.d.ts b/test/samples/path-config/output/index.d.ts index 94c2821..e8d91d7 100644 --- a/test/samples/path-config/output/index.d.ts +++ b/test/samples/path-config/output/index.d.ts @@ -1,19 +1,19 @@ declare module 'path-config' { - function foo(input: Input): Output; + export function foo(input: Input): Output; - function overload(input: Input): Output; + export function overload(input: Input): Output; - function overload(input: string): Output; + export function overload(input: string): Output; - function foo2(foo: Foo): void; - type Foo = { + export function foo2(foo: Foo): void; + export type Foo = { foo: Input; }; type Input = number; type Output = number; - function foo_nested(input: Input): Output; + export function foo_nested(input: Input): Output; - export { foo, overload, foo2, Foo, foo_nested }; + export {}; } //# sourceMappingURL=index.d.ts.map \ No newline at end of file diff --git a/test/samples/path-config/output/index.d.ts.map b/test/samples/path-config/output/index.d.ts.map index a62b5ba..419cf24 100644 --- a/test/samples/path-config/output/index.d.ts.map +++ b/test/samples/path-config/output/index.d.ts.map @@ -19,5 +19,5 @@ null, null ], - "mappings": ";UAMgBA,GAAGA;;UASfC,QAAQA;;UAARA,QAAQA;;UAgBIC,IAAIA;;;;MC/BRC,KAAKA;MACLC,MAAMA;UCGFC,UAAUA" -} \ No newline at end of file + "mappings": ";iBAMgBA,GAAGA;;iBASfC,QAAQA;;iBAARA,QAAQA;;iBAgBIC,IAAIA;;;;MC/BRC,KAAKA;MACLC,MAAMA;iBCGFC,UAAUA" +} diff --git a/test/samples/preserve-comments/output/index.d.ts b/test/samples/preserve-comments/output/index.d.ts index cf669f9..f8acd82 100644 --- a/test/samples/preserve-comments/output/index.d.ts +++ b/test/samples/preserve-comments/output/index.d.ts @@ -2,9 +2,9 @@ declare module 'preserve-comments' { /** * @deprecated */ - function a(): number; + export function a(): number; - export { a }; + export {}; } //# sourceMappingURL=index.d.ts.map \ No newline at end of file diff --git a/test/samples/preserve-comments/output/index.d.ts.map b/test/samples/preserve-comments/output/index.d.ts.map index a4d25c7..8e8d869 100644 --- a/test/samples/preserve-comments/output/index.d.ts.map +++ b/test/samples/preserve-comments/output/index.d.ts.map @@ -10,5 +10,5 @@ "sourcesContent": [ null ], - "mappings": ";;;;UAGgBA,CAACA" + "mappings": ";;;;iBAGgBA,CAACA" } \ No newline at end of file diff --git a/test/samples/preserved-jsdoc-tags/output/index.d.ts b/test/samples/preserved-jsdoc-tags/output/index.d.ts index 06e5721..59ff832 100644 --- a/test/samples/preserved-jsdoc-tags/output/index.d.ts +++ b/test/samples/preserved-jsdoc-tags/output/index.d.ts @@ -5,9 +5,9 @@ declare module 'preserved-jsdoc-tags' { * @example * const three = add(1, 2); * */ - function add(a: number, b: number): number; + export function add(a: number, b: number): number; - export { add }; + export {}; } //# sourceMappingURL=index.d.ts.map \ No newline at end of file diff --git a/test/samples/preserved-jsdoc-tags/output/index.d.ts.map b/test/samples/preserved-jsdoc-tags/output/index.d.ts.map index 95b40bc..12863e8 100644 --- a/test/samples/preserved-jsdoc-tags/output/index.d.ts.map +++ b/test/samples/preserved-jsdoc-tags/output/index.d.ts.map @@ -10,5 +10,5 @@ "sourcesContent": [ null ], - "mappings": ";;;;;;;UAQgBA,GAAGA" + "mappings": ";;;;;;;iBAQgBA,GAAGA" } \ No newline at end of file diff --git a/test/samples/throws/output/index.d.ts b/test/samples/throws/output/index.d.ts index 6267099..7167cdd 100644 --- a/test/samples/throws/output/index.d.ts +++ b/test/samples/throws/output/index.d.ts @@ -2,9 +2,9 @@ declare module 'throws' { /** * @throws {Error} nope * */ - function nope(): never; + export function nope(): never; - export { nope }; + export {}; } //# sourceMappingURL=index.d.ts.map \ No newline at end of file diff --git a/test/samples/throws/output/index.d.ts.map b/test/samples/throws/output/index.d.ts.map index bd72f09..3c74d21 100644 --- a/test/samples/throws/output/index.d.ts.map +++ b/test/samples/throws/output/index.d.ts.map @@ -10,5 +10,5 @@ "sourcesContent": [ null ], - "mappings": ";;;;UAIgBA,IAAIA" + "mappings": ";;;;iBAIgBA,IAAIA" } \ No newline at end of file diff --git a/test/samples/treeshaking-inline-import/output/index.d.ts b/test/samples/treeshaking-inline-import/output/index.d.ts index a3956aa..bc32e46 100644 --- a/test/samples/treeshaking-inline-import/output/index.d.ts +++ b/test/samples/treeshaking-inline-import/output/index.d.ts @@ -2,7 +2,7 @@ declare module 'treeshaking-inline-import' { /** * Add two vectors * */ - function add(a: Vector2, b: Vector2): Vector2; + export function add(a: Vector2, b: Vector2): Vector2; /** A vector with two components */ interface Vector2 { /** The x component */ @@ -11,7 +11,7 @@ declare module 'treeshaking-inline-import' { y: number; } - export { add }; + export {}; } //# sourceMappingURL=index.d.ts.map \ No newline at end of file diff --git a/test/samples/treeshaking-inline-import/output/index.d.ts.map b/test/samples/treeshaking-inline-import/output/index.d.ts.map index 04f37ae..780ab2a 100644 --- a/test/samples/treeshaking-inline-import/output/index.d.ts.map +++ b/test/samples/treeshaking-inline-import/output/index.d.ts.map @@ -13,5 +13,5 @@ null, null ], - "mappings": ";;;;UAMgBA,GAAGA;;WCLFC,OAAOA" + "mappings": ";;;;iBAMgBA,GAAGA;;WCLFC,OAAOA" } \ No newline at end of file diff --git a/test/samples/ts/output/index.d.ts b/test/samples/ts/output/index.d.ts index 3f3b94c..030af65 100644 --- a/test/samples/ts/output/index.d.ts +++ b/test/samples/ts/output/index.d.ts @@ -1,22 +1,22 @@ declare module 'ts' { /** A vector with two components */ - interface Vector2 { + export interface Vector2 { /** The x component */ x: number; /** The y component */ y: number; } /** A vector with three components */ - interface Vector3 extends Vector2 { + export interface Vector3 extends Vector2 { /** The z component */ z: number; } /** * Add two vectors */ - function add(a: Vector2, b: Vector2): Vector2; + export function add(a: Vector2, b: Vector2): Vector2; - export { Vector2, Vector3, add }; + export {}; } declare module 'ts/subpackage' { @@ -24,9 +24,9 @@ declare module 'ts/subpackage' { /** * Multiply two vectors */ - function multiply(a: Vector2, b: Vector2): Vector2; + export function multiply(a: Vector2, b: Vector2): Vector2; - export { multiply }; + export {}; } //# sourceMappingURL=index.d.ts.map \ No newline at end of file diff --git a/test/samples/ts/output/index.d.ts.map b/test/samples/ts/output/index.d.ts.map index a196ef8..400bc4a 100644 --- a/test/samples/ts/output/index.d.ts.map +++ b/test/samples/ts/output/index.d.ts.map @@ -15,5 +15,5 @@ null, null ], - "mappings": ";;WACiBA,OAAOA;;;;;;;WAQPC,OAAOA;;;;;;;UAQRC,GAAGA;;;;;;;;;;UCZHC,QAAQA" + "mappings": ";;kBACiBA,OAAOA;;;;;;;kBAQPC,OAAOA;;;;;;;iBAQRC,GAAGA;;;;;;;;;;iBCZHC,QAAQA" } \ No newline at end of file