From 2ce146f30e9918a78ebe0c94ba5a7d7f7c49e20f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lucas=20Treffenst=C3=A4dt?= Date: Fri, 4 Aug 2023 09:58:57 +0200 Subject: [PATCH 1/7] Add fixup for type exports When the TypeScript option isolatedModules is used, re-exported types must be exported as `export type { ... }` or `export { type ... }`. This fixup determines the kind of export (type or anything else) and adapts the export statement accordingly. --- src/transform/ExportsFixer.ts | 149 ++++++++++++++++++++++++++++++++++ src/transform/index.ts | 11 ++- 2 files changed, 156 insertions(+), 4 deletions(-) create mode 100644 src/transform/ExportsFixer.ts diff --git a/src/transform/ExportsFixer.ts b/src/transform/ExportsFixer.ts new file mode 100644 index 0000000..40055e3 --- /dev/null +++ b/src/transform/ExportsFixer.ts @@ -0,0 +1,149 @@ +import ts from "typescript"; + +type NamedExport = { + localName: string; + exportedName: string; + kind: 'type' | 'value'; +}; +type ExportDeclaration = { + location: { + start: number; + end: number; + }; + exports: Array +} + +export class ExportsFixer { + private readonly DEBUG = !!(process.env.DTS_EXPORTS_FIXER_DEBUG); + constructor(private readonly source: ts.SourceFile) {} + + public fix(): string { + const exports = this.findExports(); + exports.sort((a, b) => a.location.start - b.location.start); + return this.getCodeParts(exports).join(''); + } + + private findExports(): Array { + const { rawExports, values, types} = this.getExportsAndLocals(); + + return rawExports.map((rawExport) => { + const elements = rawExport.elements.map((e) => { + const exportedName = e.name.text; + const localName = e.propertyName?.text ?? e.name.text; + const kind = types.some(node => node.getText() === localName) && !values.some(node => node.getText() === localName) ? 'type' as const : 'value' as const; + return { + exportedName, + localName, + kind + } + }) + return { + location: { + start: rawExport.getStart(), + end: rawExport.getEnd(), + }, + exports: elements + }; + }); + } + + private getExportsAndLocals(statements: Iterable = this.source.statements) { + const rawExports: Array = []; + const values: Array = []; + const types: Array = []; + + const recurseInto = (subStatements: Iterable) => { + const { rawExports: subExports, values: subValues, types: subTypes} = this.getExportsAndLocals(subStatements); + rawExports.push(...subExports); + values.push(...subValues); + types.push(...subTypes); + }; + + for (const statement of statements) { + this.DEBUG && console.log(statement.getText(), statement.kind); + if (ts.isImportDeclaration(statement)) { + continue; + } + if (ts.isInterfaceDeclaration(statement) || ts.isTypeAliasDeclaration(statement)) { + this.DEBUG && console.log(`${statement.name.getFullText()} is a type`); + types.push(statement.name); + continue; + } + if ( + ts.isEnumDeclaration(statement) || + ts.isFunctionDeclaration(statement) || + ts.isClassDeclaration(statement) || + ts.isVariableStatement(statement) + ) { + if (ts.isVariableStatement(statement)) { + for (const declaration of statement.declarationList.declarations) { + if (ts.isIdentifier(declaration.name)) { + this.DEBUG && console.log(`${declaration.name.getFullText()} is a value (from var statement)`); + values.push(declaration.name); + } + } + } else { + if (statement.name) { + this.DEBUG && console.log(`${statement.name.getFullText()} is a value (from declaration)`); + values.push(statement.name); + } + } + continue; + } + if (ts.isModuleBlock(statement)) { + const subStatements = statement.statements; + recurseInto(subStatements); + continue; + } + if (ts.isModuleDeclaration(statement)) { + recurseInto(statement.getChildren()); + continue; + } + if (ts.isExportDeclaration(statement)) { + if (statement.moduleSpecifier) { + continue; + } + if (statement.isTypeOnly) { + // no fixup neccessary + continue; + } + const exportClause = statement.exportClause; + if (!exportClause || !ts.isNamedExports(exportClause)) { + continue; + } + rawExports.push(exportClause); + continue; + } + this.DEBUG && console.log('unhandled statement', statement.getFullText(), statement.kind); + } + return { rawExports, values, types }; + } + + private createNamedExport(exportSpec: NamedExport, elideType = false) { + return `${!elideType && exportSpec.kind === 'type' ? 'type ' : ''}${exportSpec.localName}${exportSpec.localName === exportSpec.exportedName ? '' : ` as ${exportSpec.exportedName}`}`; + } + + private getCodeParts(exports: Array) { + let cursor = 0; + const code = this.source.getFullText(); + const parts: Array = []; + for (const exportDeclaration of exports) { + const head = code.slice(cursor, exportDeclaration.location.start); + if (head.length > 0) { + parts.push(head); + } + parts.push(this.getExportStatement(exportDeclaration)); + + cursor = exportDeclaration.location.end; + } + if (cursor < code.length) { + parts.push(code.slice(cursor)); + } + return parts; + } + + private getExportStatement(exportDeclaration: ExportDeclaration) { + const isTypeOnly = exportDeclaration.exports.every((e) => e.kind === 'type') && exportDeclaration.exports.length > 0; + return `${isTypeOnly ? 'type ' : ''}{ ${exportDeclaration.exports.map((exp) => this.createNamedExport(exp, isTypeOnly)).join(', ')} }` + } +} diff --git a/src/transform/index.ts b/src/transform/index.ts index a19ee20..60040b7 100644 --- a/src/transform/index.ts +++ b/src/transform/index.ts @@ -4,6 +4,7 @@ import ts from "typescript"; import { NamespaceFixer } from "./NamespaceFixer.js"; import { preProcess } from "./preprocess.js"; import { convert } from "./Transformer.js"; +import {ExportsFixer} from "./ExportsFixer.js"; function parse(fileName: string, code: string): ts.SourceFile { return ts.createSourceFile(fileName, code, ts.ScriptTarget.Latest, true); @@ -91,8 +92,8 @@ export const transform = () => { return { code, ast: converted.ast as any, map: preprocessed.code.generateMap() as any }; }, - renderChunk(code, chunk, options) { - const source = parse(chunk.fileName, code); + renderChunk(inputCode, chunk, options) { + const source = parse(chunk.fileName, inputCode); const fixer = new NamespaceFixer(source); const typeReferences = new Set(); @@ -120,7 +121,7 @@ export const transform = () => { } } - code = writeBlock(Array.from(fileReferences, (ref) => `/// `)); + let code = writeBlock(Array.from(fileReferences, (ref) => `/// `)); code += writeBlock(Array.from(typeReferences, (ref) => `/// `)); code += fixer.fix(); @@ -128,7 +129,9 @@ export const transform = () => { code += "\nexport { }"; } - return { code, map: { mappings: "" } }; + const exportsFixer = new ExportsFixer(parse(chunk.fileName, code)); + + return { code: exportsFixer.fix(), map: { mappings: "" } }; }, } satisfies Plugin; }; From 7f34086ab808bde4a82d2e7491b4d7ed1e3e15a5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lucas=20Treffenst=C3=A4dt?= Date: Fri, 4 Aug 2023 09:59:49 +0200 Subject: [PATCH 2/7] Adapt test cases for type exports --- tests/testcases/call-signature/expected.d.ts | 2 +- .../testcases/computed-property/expected.d.ts | 2 +- .../construct-signature/expected.d.ts | 2 +- tests/testcases/custom-tsconfig/expected.d.ts | 2 +- .../export-as-namespace/expected.d.ts | 2 +- .../export-default-interface/expected.d.ts | 2 +- .../export-empty-object/expected.d.ts | 2 +- .../export-multiple-vars/expected.d.ts | 2 +- .../export-simple-alias/expected.d.ts | 2 +- .../export-simple-interface/expected.d.ts | 2 +- tests/testcases/export-star-as/expected.d.ts | 4 +--- tests/testcases/export-star/expected.d.ts | 2 +- tests/testcases/externals-link/expected.d.ts | 2 +- tests/testcases/externals/expected.d.ts | 2 +- tests/testcases/generic-extends/expected.d.ts | 2 +- tests/testcases/generics/expected.d.ts | 2 +- .../implements-expression/expected.d.ts | 2 +- .../import-default-interface/expected.d.ts | 2 +- .../import-no-import-clause/expected.d.ts | 2 +- .../import-referenced-interface/expected.d.ts | 2 +- tests/testcases/import-renamed/expected.d.ts | 2 +- .../import-unused-interface/expected.d.ts | 2 +- .../expected.d.ts | 2 +- .../inline-import-generic/expected.d.ts | 2 +- .../inline-import-namespace/expected.d.ts | 7 ++----- .../expected.d.ts | 2 +- tests/testcases/inline-import/expected.d.ts | 2 +- .../expected.d.ts | 4 ++-- .../issue-160-global-namespace/expected.d.ts | 6 +++--- .../expected.d.ts | 5 +---- tests/testcases/issue-217/expected.d.ts | 5 +---- tests/testcases/issue-254/expected.d.ts | 2 +- tests/testcases/issue-87/expected.d.ts | 2 +- .../issue-89-import-equals/expected.d.ts | 2 +- .../issue-91-extra-semicolon/expected.d.ts | 2 +- .../keep-extended-interface/expected.d.ts | 2 +- .../keep-interface-definition/expected.d.ts | 2 +- .../keep-referenced-interface/expected.d.ts | 2 +- .../labeled-tuple-types/expected.d.ts | 2 +- .../multiple-entries-cjs/expected.d.ts | 8 ++++---- .../multiple-entries-mjs/expected.d.ts | 8 ++++---- .../expected.d.ts | 2 +- .../testcases/multiple-entries/expected.d.ts | 8 ++++---- .../namespace-keyword-exports/expected.d.ts | 4 +--- .../namespace-references/expected.d.ts | 2 +- tests/testcases/optional-type/expected.d.ts | 2 +- .../expected.d.ts | 19 ++++--------------- .../re-export-namespace/expected.d.ts | 13 +------------ .../testcases/react-components/expected.d.ts | 2 +- .../expected.d.ts | 2 +- .../remapped-mapped-types/expected.d.ts | 2 +- .../remove-unexported-interface/expected.d.ts | 2 +- tests/testcases/renaming/expected.d.ts | 2 +- tests/testcases/shadowing/expected.d.ts | 2 +- .../testcases/spread-tuple-type/expected.d.ts | 2 +- tests/testcases/ts42-abstract/expected.d.ts | 2 +- tests/testcases/ts42-tuple-rest/expected.d.ts | 2 +- tests/testcases/ts43-getset/expected.d.ts | 2 +- tests/testcases/ts47/expected.d.ts | 2 +- tests/testcases/ts48/expected.d.ts | 2 +- .../testcases/type-conditional/expected.d.ts | 2 +- .../testcases/type-constructor/expected.d.ts | 2 +- tests/testcases/type-function/expected.d.ts | 2 +- tests/testcases/type-index/expected.d.ts | 2 +- tests/testcases/type-literal/expected.d.ts | 2 +- tests/testcases/type-mapped/expected.d.ts | 2 +- tests/testcases/type-simple/expected.d.ts | 2 +- .../type-template-literals/expected.d.ts | 2 +- .../using-mts-cts-files/expected.d.ts | 8 ++++---- .../using-namespace-import/expected.d.ts | 2 +- tests/testcases/using-ts-files/expected.d.ts | 8 ++++---- .../variadic-tuple-types/expected.d.ts | 2 +- 72 files changed, 94 insertions(+), 129 deletions(-) diff --git a/tests/testcases/call-signature/expected.d.ts b/tests/testcases/call-signature/expected.d.ts index 591fc33..ec217ac 100644 --- a/tests/testcases/call-signature/expected.d.ts +++ b/tests/testcases/call-signature/expected.d.ts @@ -6,4 +6,4 @@ declare const fn: { (arg: string): string; staticProp: string; }; -export { I, fn }; +export { type I, fn }; diff --git a/tests/testcases/computed-property/expected.d.ts b/tests/testcases/computed-property/expected.d.ts index c87f05d..b6519ef 100644 --- a/tests/testcases/computed-property/expected.d.ts +++ b/tests/testcases/computed-property/expected.d.ts @@ -10,4 +10,4 @@ type Klass = { [0]: C; [Dprop]: D; }; -export { Klass }; +export type { Klass }; diff --git a/tests/testcases/construct-signature/expected.d.ts b/tests/testcases/construct-signature/expected.d.ts index c5c09f1..7911b96 100644 --- a/tests/testcases/construct-signature/expected.d.ts +++ b/tests/testcases/construct-signature/expected.d.ts @@ -1,4 +1,4 @@ interface Foo { new (): any; } -export { Foo }; +export type { Foo }; diff --git a/tests/testcases/custom-tsconfig/expected.d.ts b/tests/testcases/custom-tsconfig/expected.d.ts index 0ec4ada..8e3ff49 100644 --- a/tests/testcases/custom-tsconfig/expected.d.ts +++ b/tests/testcases/custom-tsconfig/expected.d.ts @@ -1,2 +1,2 @@ interface Foo {} -export { Foo }; +export type { Foo }; diff --git a/tests/testcases/export-as-namespace/expected.d.ts b/tests/testcases/export-as-namespace/expected.d.ts index 0ec4ada..8e3ff49 100644 --- a/tests/testcases/export-as-namespace/expected.d.ts +++ b/tests/testcases/export-as-namespace/expected.d.ts @@ -1,2 +1,2 @@ interface Foo {} -export { Foo }; +export type { Foo }; diff --git a/tests/testcases/export-default-interface/expected.d.ts b/tests/testcases/export-default-interface/expected.d.ts index f5ac4ef..a9af0fa 100644 --- a/tests/testcases/export-default-interface/expected.d.ts +++ b/tests/testcases/export-default-interface/expected.d.ts @@ -1,2 +1,2 @@ interface Foo {} -export { Foo as default }; +export type { Foo as default }; diff --git a/tests/testcases/export-empty-object/expected.d.ts b/tests/testcases/export-empty-object/expected.d.ts index f0a766d..62926bb 100644 --- a/tests/testcases/export-empty-object/expected.d.ts +++ b/tests/testcases/export-empty-object/expected.d.ts @@ -1 +1 @@ -export { } +export { } diff --git a/tests/testcases/export-multiple-vars/expected.d.ts b/tests/testcases/export-multiple-vars/expected.d.ts index d0e69a6..2aaf856 100644 --- a/tests/testcases/export-multiple-vars/expected.d.ts +++ b/tests/testcases/export-multiple-vars/expected.d.ts @@ -9,4 +9,4 @@ declare const options: { declare const params: { normalize: (inVar: In) => Out; }; -export { In, Out, config, options, params }; +export { type In, type Out, config, options, params }; diff --git a/tests/testcases/export-simple-alias/expected.d.ts b/tests/testcases/export-simple-alias/expected.d.ts index d4d9e35..be126ab 100644 --- a/tests/testcases/export-simple-alias/expected.d.ts +++ b/tests/testcases/export-simple-alias/expected.d.ts @@ -1,3 +1,3 @@ interface Foo {} declare type Bar = Foo; -export { Bar }; +export type { Bar }; diff --git a/tests/testcases/export-simple-interface/expected.d.ts b/tests/testcases/export-simple-interface/expected.d.ts index 0ec4ada..8e3ff49 100644 --- a/tests/testcases/export-simple-interface/expected.d.ts +++ b/tests/testcases/export-simple-interface/expected.d.ts @@ -1,2 +1,2 @@ interface Foo {} -export { Foo }; +export type { Foo }; diff --git a/tests/testcases/export-star-as/expected.d.ts b/tests/testcases/export-star-as/expected.d.ts index 97cd317..fdacd83 100644 --- a/tests/testcases/export-star-as/expected.d.ts +++ b/tests/testcases/export-star-as/expected.d.ts @@ -1,8 +1,6 @@ interface A {} type foo_d_A = A; declare namespace foo_d { - export { - foo_d_A as A, - }; + export type { foo_d_A as A }; } export { foo_d as foo }; diff --git a/tests/testcases/export-star/expected.d.ts b/tests/testcases/export-star/expected.d.ts index 753bd2c..77e633f 100644 --- a/tests/testcases/export-star/expected.d.ts +++ b/tests/testcases/export-star/expected.d.ts @@ -1,3 +1,3 @@ interface B {} declare class A {} -export { A, B }; +export { A, type B }; diff --git a/tests/testcases/externals-link/expected.d.ts b/tests/testcases/externals-link/expected.d.ts index 52d4b6f..29a3fc3 100644 --- a/tests/testcases/externals-link/expected.d.ts +++ b/tests/testcases/externals-link/expected.d.ts @@ -2,4 +2,4 @@ * Container element type usable for mouse/touch functions */ type DragContainerElement = HTMLElement | SVGSVGElement | SVGGElement; -export { DragContainerElement }; +export type { DragContainerElement }; diff --git a/tests/testcases/externals/expected.d.ts b/tests/testcases/externals/expected.d.ts index 109dbbe..a37ffe4 100644 --- a/tests/testcases/externals/expected.d.ts +++ b/tests/testcases/externals/expected.d.ts @@ -10,4 +10,4 @@ export { ReactFragment } from 'react'; * Container element type usable for mouse/touch functions */ type DragContainerElement = HTMLElement | SVGSVGElement | SVGGElement; -export { DragContainerElement }; +export type { DragContainerElement }; diff --git a/tests/testcases/generic-extends/expected.d.ts b/tests/testcases/generic-extends/expected.d.ts index 8e1b6cb..690235d 100644 --- a/tests/testcases/generic-extends/expected.d.ts +++ b/tests/testcases/generic-extends/expected.d.ts @@ -3,4 +3,4 @@ type AnimatedProps = T; type AnimatedComponent = ForwardRefExoticComponent< AnimatedProps> >; -export { AnimatedComponent, AnimatedProps }; +export type { AnimatedComponent, AnimatedProps }; diff --git a/tests/testcases/generics/expected.d.ts b/tests/testcases/generics/expected.d.ts index d8282d7..9b9b261 100644 --- a/tests/testcases/generics/expected.d.ts +++ b/tests/testcases/generics/expected.d.ts @@ -30,4 +30,4 @@ declare function fn(g: T, h: Gen): void; declare type TyFn = (j: T, k: Gen) => L; declare type TyCtor = new (m: T, n: Gen) => O; interface I2 extends Gen

{} -export { Cl, I1, I2, Ty, TyCtor, TyFn, fn }; +export { Cl, type I1, type I2, type Ty, type TyCtor, type TyFn, fn }; diff --git a/tests/testcases/implements-expression/expected.d.ts b/tests/testcases/implements-expression/expected.d.ts index 4e46b02..2f10dc6 100644 --- a/tests/testcases/implements-expression/expected.d.ts +++ b/tests/testcases/implements-expression/expected.d.ts @@ -11,4 +11,4 @@ interface MyComponentProps extends ns.Props { bar: string; } declare class MyComponent extends ns.Component {} -export { MyComponent, MyComponentProps }; +export { MyComponent, type MyComponentProps }; diff --git a/tests/testcases/import-default-interface/expected.d.ts b/tests/testcases/import-default-interface/expected.d.ts index a88fb08..f0d1370 100644 --- a/tests/testcases/import-default-interface/expected.d.ts +++ b/tests/testcases/import-default-interface/expected.d.ts @@ -1,3 +1,3 @@ interface Bar {} interface Foo extends Bar {} -export { Foo }; +export type { Foo }; diff --git a/tests/testcases/import-no-import-clause/expected.d.ts b/tests/testcases/import-no-import-clause/expected.d.ts index 0ec4ada..8e3ff49 100644 --- a/tests/testcases/import-no-import-clause/expected.d.ts +++ b/tests/testcases/import-no-import-clause/expected.d.ts @@ -1,2 +1,2 @@ interface Foo {} -export { Foo }; +export type { Foo }; diff --git a/tests/testcases/import-referenced-interface/expected.d.ts b/tests/testcases/import-referenced-interface/expected.d.ts index b3279e7..eeae72f 100644 --- a/tests/testcases/import-referenced-interface/expected.d.ts +++ b/tests/testcases/import-referenced-interface/expected.d.ts @@ -2,4 +2,4 @@ interface Bar {} interface Foo { bar: Bar; } -export { Foo }; +export type { Foo }; diff --git a/tests/testcases/import-renamed/expected.d.ts b/tests/testcases/import-renamed/expected.d.ts index b3279e7..eeae72f 100644 --- a/tests/testcases/import-renamed/expected.d.ts +++ b/tests/testcases/import-renamed/expected.d.ts @@ -2,4 +2,4 @@ interface Bar {} interface Foo { bar: Bar; } -export { Foo }; +export type { Foo }; diff --git a/tests/testcases/import-unused-interface/expected.d.ts b/tests/testcases/import-unused-interface/expected.d.ts index 0ec4ada..8e3ff49 100644 --- a/tests/testcases/import-unused-interface/expected.d.ts +++ b/tests/testcases/import-unused-interface/expected.d.ts @@ -1,2 +1,2 @@ interface Foo {} -export { Foo }; +export type { Foo }; diff --git a/tests/testcases/inline-import-external-namespace/expected.d.ts b/tests/testcases/inline-import-external-namespace/expected.d.ts index fc249e3..010f3c9 100644 --- a/tests/testcases/inline-import-external-namespace/expected.d.ts +++ b/tests/testcases/inline-import-external-namespace/expected.d.ts @@ -3,4 +3,4 @@ interface Foo { ns1: foo; ns2: typeof foo; } -export { Foo }; +export type { Foo }; diff --git a/tests/testcases/inline-import-generic/expected.d.ts b/tests/testcases/inline-import-generic/expected.d.ts index 6ecada7..897a684 100644 --- a/tests/testcases/inline-import-generic/expected.d.ts +++ b/tests/testcases/inline-import-generic/expected.d.ts @@ -4,4 +4,4 @@ interface Bar { interface Foo { bar: Bar; } -export { Foo }; +export type { Foo }; diff --git a/tests/testcases/inline-import-namespace/expected.d.ts b/tests/testcases/inline-import-namespace/expected.d.ts index e5b1008..6e09fa3 100644 --- a/tests/testcases/inline-import-namespace/expected.d.ts +++ b/tests/testcases/inline-import-namespace/expected.d.ts @@ -4,12 +4,9 @@ type __bar_Bar = Bar; declare const __bar_Bar: typeof Bar; type __bar_IBar = IBar; declare namespace __bar { - export { - __bar_Bar as Bar, - __bar_IBar as IBar, - }; + export { __bar_Bar as Bar, type __bar_IBar as IBar }; } interface Foo { ns: typeof __bar; } -export { Foo }; +export type { Foo }; diff --git a/tests/testcases/inline-import-typeof-members/expected.d.ts b/tests/testcases/inline-import-typeof-members/expected.d.ts index 1917d59..9c4a65a 100644 --- a/tests/testcases/inline-import-typeof-members/expected.d.ts +++ b/tests/testcases/inline-import-typeof-members/expected.d.ts @@ -4,4 +4,4 @@ type TypeScript = typeof typescript; interface Test { rollup: rollup.RollupOptions; } -export { Test, TypeScript }; +export type { Test, TypeScript }; diff --git a/tests/testcases/inline-import/expected.d.ts b/tests/testcases/inline-import/expected.d.ts index ac54f06..d981236 100644 --- a/tests/testcases/inline-import/expected.d.ts +++ b/tests/testcases/inline-import/expected.d.ts @@ -4,4 +4,4 @@ interface Foo { bar: Bar; baz: typeof Baz; } -export { Foo }; +export type { Foo }; diff --git a/tests/testcases/issue-128-reference-directive/expected.d.ts b/tests/testcases/issue-128-reference-directive/expected.d.ts index b4efc01..56e94e7 100644 --- a/tests/testcases/issue-128-reference-directive/expected.d.ts +++ b/tests/testcases/issue-128-reference-directive/expected.d.ts @@ -5,8 +5,8 @@ export { B } from './>main-b<.js'; declare const A = 2; declare type JSXElements = keyof JSX.IntrinsicElements; declare const a: JSXElements[]; -export { A, JSXElements, a }; +export { A, type JSXElements, a }; // >main-b<.d.ts /// interface B {} -export { B }; +export type { B }; diff --git a/tests/testcases/issue-160-global-namespace/expected.d.ts b/tests/testcases/issue-160-global-namespace/expected.d.ts index 4f6b34c..6dac529 100644 --- a/tests/testcases/issue-160-global-namespace/expected.d.ts +++ b/tests/testcases/issue-160-global-namespace/expected.d.ts @@ -2,10 +2,10 @@ interface A {} interface B {} declare global { namespace Named.Core { - export { A, B }; + export type { A, B }; } namespace Foo.Bar.Baz.Quux { - export { A, B }; + export type { A, B }; } } -export { A }; +export type { A }; diff --git a/tests/testcases/issue-185-hoist-generic-extends/expected.d.ts b/tests/testcases/issue-185-hoist-generic-extends/expected.d.ts index e2eac7a..a332c31 100644 --- a/tests/testcases/issue-185-hoist-generic-extends/expected.d.ts +++ b/tests/testcases/issue-185-hoist-generic-extends/expected.d.ts @@ -7,9 +7,6 @@ type a_d_Props = Props; type a_d_System = System; declare const a_d_System: typeof System; declare namespace a_d { - export { - a_d_Props as Props, - a_d_System as System, - }; + export { type a_d_Props as Props, a_d_System as System }; } export { a_d as A }; diff --git a/tests/testcases/issue-217/expected.d.ts b/tests/testcases/issue-217/expected.d.ts index 787142a..005e533 100644 --- a/tests/testcases/issue-217/expected.d.ts +++ b/tests/testcases/issue-217/expected.d.ts @@ -5,9 +5,6 @@ declare const dog: Example<"hi">; type example_d_Example = Example; declare const example_d_dog: typeof dog; declare namespace example_d { - export { - example_d_Example as Example, - example_d_dog as dog, - }; + export { type example_d_Example as Example, example_d_dog as dog }; } export { example_d as types }; diff --git a/tests/testcases/issue-254/expected.d.ts b/tests/testcases/issue-254/expected.d.ts index 79d7244..443b266 100644 --- a/tests/testcases/issue-254/expected.d.ts +++ b/tests/testcases/issue-254/expected.d.ts @@ -5,4 +5,4 @@ interface Foo { declare namespace Bar { export enum F {} } -export { Bar, Foo }; +export { Bar, type Foo }; diff --git a/tests/testcases/issue-87/expected.d.ts b/tests/testcases/issue-87/expected.d.ts index a04cc1e..b1b8b8d 100644 --- a/tests/testcases/issue-87/expected.d.ts +++ b/tests/testcases/issue-87/expected.d.ts @@ -11,4 +11,4 @@ interface Cache2 { destroy: () => void; } declare const Cache2: () => Cache2; -export { Cache, Cache2, CacheInfo, uniqueId }; +export { Cache, Cache2, type CacheInfo, uniqueId }; diff --git a/tests/testcases/issue-89-import-equals/expected.d.ts b/tests/testcases/issue-89-import-equals/expected.d.ts index 0ec4ada..8e3ff49 100644 --- a/tests/testcases/issue-89-import-equals/expected.d.ts +++ b/tests/testcases/issue-89-import-equals/expected.d.ts @@ -1,2 +1,2 @@ interface Foo {} -export { Foo }; +export type { Foo }; diff --git a/tests/testcases/issue-91-extra-semicolon/expected.d.ts b/tests/testcases/issue-91-extra-semicolon/expected.d.ts index 5c292c8..e6e0fe3 100644 --- a/tests/testcases/issue-91-extra-semicolon/expected.d.ts +++ b/tests/testcases/issue-91-extra-semicolon/expected.d.ts @@ -1,4 +1,4 @@ interface Connection { uri: string; } -export { Connection }; +export type { Connection }; diff --git a/tests/testcases/keep-extended-interface/expected.d.ts b/tests/testcases/keep-extended-interface/expected.d.ts index a88fb08..f0d1370 100644 --- a/tests/testcases/keep-extended-interface/expected.d.ts +++ b/tests/testcases/keep-extended-interface/expected.d.ts @@ -1,3 +1,3 @@ interface Bar {} interface Foo extends Bar {} -export { Foo }; +export type { Foo }; diff --git a/tests/testcases/keep-interface-definition/expected.d.ts b/tests/testcases/keep-interface-definition/expected.d.ts index 05e792c..9b1d6e1 100644 --- a/tests/testcases/keep-interface-definition/expected.d.ts +++ b/tests/testcases/keep-interface-definition/expected.d.ts @@ -2,4 +2,4 @@ interface Foo { a: string; b: Array; } -export { Foo }; +export type { Foo }; diff --git a/tests/testcases/keep-referenced-interface/expected.d.ts b/tests/testcases/keep-referenced-interface/expected.d.ts index b3279e7..eeae72f 100644 --- a/tests/testcases/keep-referenced-interface/expected.d.ts +++ b/tests/testcases/keep-referenced-interface/expected.d.ts @@ -2,4 +2,4 @@ interface Bar {} interface Foo { bar: Bar; } -export { Foo }; +export type { Foo }; diff --git a/tests/testcases/labeled-tuple-types/expected.d.ts b/tests/testcases/labeled-tuple-types/expected.d.ts index 7d6e1a1..1e5e5e4 100644 --- a/tests/testcases/labeled-tuple-types/expected.d.ts +++ b/tests/testcases/labeled-tuple-types/expected.d.ts @@ -1,2 +1,2 @@ type Foo = [first: number, second?: string, ...rest: any[]]; -export { Foo }; +export type { Foo }; diff --git a/tests/testcases/multiple-entries-cjs/expected.d.ts b/tests/testcases/multiple-entries-cjs/expected.d.ts index 1ae3578..91017fc 100644 --- a/tests/testcases/multiple-entries-cjs/expected.d.ts +++ b/tests/testcases/multiple-entries-cjs/expected.d.ts @@ -1,8 +1,8 @@ // main-a.d.cts -export { A } from './main-b.d-beb2139a.js'; +export { A } from './main-b.d-e5346d3a.js'; // main-b.d.cts -export { B } from './main-b.d-beb2139a.js'; -// main-b.d-beb2139a.d.ts +export { B } from './main-b.d-e5346d3a.js'; +// main-b.d-e5346d3a.d.ts interface A {} interface B {} -export { A, B }; +export type { A, B }; diff --git a/tests/testcases/multiple-entries-mjs/expected.d.ts b/tests/testcases/multiple-entries-mjs/expected.d.ts index d3ee12e..b819bf0 100644 --- a/tests/testcases/multiple-entries-mjs/expected.d.ts +++ b/tests/testcases/multiple-entries-mjs/expected.d.ts @@ -1,8 +1,8 @@ // main-a.d.mts -export { A } from './main-b.d-beb2139a.mjs'; +export { A } from './main-b.d-e5346d3a.mjs'; // main-b.d.mts -export { B } from './main-b.d-beb2139a.mjs'; -// main-b.d-beb2139a.d.mts +export { B } from './main-b.d-e5346d3a.mjs'; +// main-b.d-e5346d3a.d.mts interface A {} interface B {} -export { A, B }; +export type { A, B }; diff --git a/tests/testcases/multiple-entries-multiple-tsconfigs/expected.d.ts b/tests/testcases/multiple-entries-multiple-tsconfigs/expected.d.ts index a526416..e0620f1 100644 --- a/tests/testcases/multiple-entries-multiple-tsconfigs/expected.d.ts +++ b/tests/testcases/multiple-entries-multiple-tsconfigs/expected.d.ts @@ -2,7 +2,7 @@ interface A {} interface B {} interface I {} -export { A, B, I }; +export type { A, B, I }; // entry-a.d.ts export { A } from './index.js'; // entry-b.d.ts diff --git a/tests/testcases/multiple-entries/expected.d.ts b/tests/testcases/multiple-entries/expected.d.ts index 7f98cb8..a8f358d 100644 --- a/tests/testcases/multiple-entries/expected.d.ts +++ b/tests/testcases/multiple-entries/expected.d.ts @@ -1,8 +1,8 @@ // >main-a<.d.ts -export { A } from './main-b.d-beb2139a.js'; +export { A } from './main-b.d-e5346d3a.js'; // >main-b<.d.ts -export { B } from './main-b.d-beb2139a.js'; -// main-b.d-beb2139a.d.ts +export { B } from './main-b.d-e5346d3a.js'; +// main-b.d-e5346d3a.d.ts interface A {} interface B {} -export { A, B }; +export type { A, B }; diff --git a/tests/testcases/namespace-keyword-exports/expected.d.ts b/tests/testcases/namespace-keyword-exports/expected.d.ts index fd736b1..f4af67e 100644 --- a/tests/testcases/namespace-keyword-exports/expected.d.ts +++ b/tests/testcases/namespace-keyword-exports/expected.d.ts @@ -1,7 +1,5 @@ declare const _in = "foo"; declare namespace foo_d { - export { - _in as in, - }; + export { _in as in }; } export { foo_d as foo }; diff --git a/tests/testcases/namespace-references/expected.d.ts b/tests/testcases/namespace-references/expected.d.ts index f4c29cb..0887f29 100644 --- a/tests/testcases/namespace-references/expected.d.ts +++ b/tests/testcases/namespace-references/expected.d.ts @@ -13,7 +13,7 @@ declare namespace ns { e: typeof Shadowed4; } namespace childNS { - export { Referenced2 as ref }; + export type { Referenced2 as ref }; } } export { ns }; diff --git a/tests/testcases/optional-type/expected.d.ts b/tests/testcases/optional-type/expected.d.ts index d56285c..3618be1 100644 --- a/tests/testcases/optional-type/expected.d.ts +++ b/tests/testcases/optional-type/expected.d.ts @@ -1,2 +1,2 @@ declare type DateRange = [Date?, Date?]; -export { DateRange }; +export type { DateRange }; diff --git a/tests/testcases/re-export-namespace-multiple/expected.d.ts b/tests/testcases/re-export-namespace-multiple/expected.d.ts index 05e3377..82b38f5 100644 --- a/tests/testcases/re-export-namespace-multiple/expected.d.ts +++ b/tests/testcases/re-export-namespace-multiple/expected.d.ts @@ -16,27 +16,16 @@ declare const defs_d_D: typeof D; declare const defs_d_E: typeof E; type defs_d_F = F; declare namespace defs_d { - export { - defs_d_A as A, - defs_d_B as B, - defs_d_C as C, - defs_d_D as D, - defs_d_E as E, - defs_d_F as F, - }; + export { type defs_d_A as A, defs_d_B as B, defs_d_C as C, defs_d_D as D, defs_d_E as E, type defs_d_F as F }; } declare namespace deep_d { - export { - defs_d as ns, - }; + export { defs_d as ns }; } type onlyOne_d_A = A; declare namespace onlyOne_d { - export { - onlyOne_d_A as A, - }; + export type { onlyOne_d_A as A }; } interface WithA { a: A; } -export { WithA, deep_d as deep, defs_d as ns, onlyOne_d as onlyOne }; +export { type WithA, deep_d as deep, defs_d as ns, onlyOne_d as onlyOne }; diff --git a/tests/testcases/re-export-namespace/expected.d.ts b/tests/testcases/re-export-namespace/expected.d.ts index bae2748..1a893f3 100644 --- a/tests/testcases/re-export-namespace/expected.d.ts +++ b/tests/testcases/re-export-namespace/expected.d.ts @@ -25,17 +25,6 @@ declare const namespace_d_GenericF: typeof GenericF; type namespace_d_GenericI = GenericI; type namespace_d_GenericT = GenericT; declare namespace namespace_d { - export { - namespace_d_A as A, - namespace_d_B as B, - namespace_d_C as C, - namespace_d_D as D, - namespace_d_E as E, - namespace_d_F as F, - namespace_d_GenericC as GenericC, - namespace_d_GenericF as GenericF, - namespace_d_GenericI as GenericI, - namespace_d_GenericT as GenericT, - }; + export { type namespace_d_A as A, namespace_d_B as B, namespace_d_C as C, namespace_d_D as D, namespace_d_E as E, type namespace_d_F as F, namespace_d_GenericC as GenericC, namespace_d_GenericF as GenericF, type namespace_d_GenericI as GenericI, type namespace_d_GenericT as GenericT }; } export { namespace_d as ns1, namespace_d as ns2 }; diff --git a/tests/testcases/react-components/expected.d.ts b/tests/testcases/react-components/expected.d.ts index 860fca8..df33386 100644 --- a/tests/testcases/react-components/expected.d.ts +++ b/tests/testcases/react-components/expected.d.ts @@ -3,4 +3,4 @@ interface MyComponentProps extends React.HtmlHTMLAttributes { foo: string; } declare class MyComponent extends React.Component {} -export { MyComponent, MyComponentProps }; +export { MyComponent, type MyComponentProps }; diff --git a/tests/testcases/reference-path-remapping-should-not-touch-absolute-path/expected.d.ts b/tests/testcases/reference-path-remapping-should-not-touch-absolute-path/expected.d.ts index 7efd85d..e717e61 100644 --- a/tests/testcases/reference-path-remapping-should-not-touch-absolute-path/expected.d.ts +++ b/tests/testcases/reference-path-remapping-should-not-touch-absolute-path/expected.d.ts @@ -1,3 +1,3 @@ /// interface Hello {} -export { Hello }; +export type { Hello }; diff --git a/tests/testcases/remapped-mapped-types/expected.d.ts b/tests/testcases/remapped-mapped-types/expected.d.ts index f84fff2..9770ab7 100644 --- a/tests/testcases/remapped-mapped-types/expected.d.ts +++ b/tests/testcases/remapped-mapped-types/expected.d.ts @@ -16,4 +16,4 @@ interface Circle { radius: number; } type KindlessCircle = RemoveKindField; -export { KindlessCircle, LazyPerson }; +export type { KindlessCircle, LazyPerson }; diff --git a/tests/testcases/remove-unexported-interface/expected.d.ts b/tests/testcases/remove-unexported-interface/expected.d.ts index 0ec4ada..8e3ff49 100644 --- a/tests/testcases/remove-unexported-interface/expected.d.ts +++ b/tests/testcases/remove-unexported-interface/expected.d.ts @@ -1,2 +1,2 @@ interface Foo {} -export { Foo }; +export type { Foo }; diff --git a/tests/testcases/renaming/expected.d.ts b/tests/testcases/renaming/expected.d.ts index d8e0b46..9c35746 100644 --- a/tests/testcases/renaming/expected.d.ts +++ b/tests/testcases/renaming/expected.d.ts @@ -32,4 +32,4 @@ declare function Func(d: D): E; declare type Type = { f: F; }; -export { Func$1 as AFunc, Interface$1 as AInterface, Klass$1 as AKlass, Type$1 as AType, Func as BFunc, Interface as BInterface, Klass as BKlass, Type as BType }; +export { Func$1 as AFunc, type Interface$1 as AInterface, Klass$1 as AKlass, type Type$1 as AType, Func as BFunc, type Interface as BInterface, Klass as BKlass, type Type as BType }; diff --git a/tests/testcases/shadowing/expected.d.ts b/tests/testcases/shadowing/expected.d.ts index a7ec978..fb808df 100644 --- a/tests/testcases/shadowing/expected.d.ts +++ b/tests/testcases/shadowing/expected.d.ts @@ -16,4 +16,4 @@ declare type GenericType = { l: L; }; interface GenericExtends extends GenericInterface {} -export { ConditionalInfer, GenericExtends, GenericInterface, GenericKlass, GenericType, Mapped, genericFunction }; +export { type ConditionalInfer, type GenericExtends, type GenericInterface, GenericKlass, type GenericType, type Mapped, genericFunction }; diff --git a/tests/testcases/spread-tuple-type/expected.d.ts b/tests/testcases/spread-tuple-type/expected.d.ts index 9a7c977..3e8d011 100644 --- a/tests/testcases/spread-tuple-type/expected.d.ts +++ b/tests/testcases/spread-tuple-type/expected.d.ts @@ -1,2 +1,2 @@ declare type SpreadedTuple = [number, ...string[]]; -export { SpreadedTuple }; +export type { SpreadedTuple }; diff --git a/tests/testcases/ts42-abstract/expected.d.ts b/tests/testcases/ts42-abstract/expected.d.ts index 6b9c2fc..1baa526 100644 --- a/tests/testcases/ts42-abstract/expected.d.ts +++ b/tests/testcases/ts42-abstract/expected.d.ts @@ -6,4 +6,4 @@ declare abstract class AbstractClass { member: AbstractMember; } type AbstractConstructor = abstract new (...args: any[]) => T; -export { AbstractConstructor }; +export type { AbstractConstructor }; diff --git a/tests/testcases/ts42-tuple-rest/expected.d.ts b/tests/testcases/ts42-tuple-rest/expected.d.ts index d9e8283..15570d0 100644 --- a/tests/testcases/ts42-tuple-rest/expected.d.ts +++ b/tests/testcases/ts42-tuple-rest/expected.d.ts @@ -2,4 +2,4 @@ interface Leading {} interface Middle {} type UsesLeading = [...Array, number]; type UsesMiddle = [boolean, ...Array, boolean]; -export { UsesLeading, UsesMiddle }; +export type { UsesLeading, UsesMiddle }; diff --git a/tests/testcases/ts43-getset/expected.d.ts b/tests/testcases/ts43-getset/expected.d.ts index df57a30..6fe5075 100644 --- a/tests/testcases/ts43-getset/expected.d.ts +++ b/tests/testcases/ts43-getset/expected.d.ts @@ -4,4 +4,4 @@ interface Thing { get size(): GetT; set size(value: GetT | SetT | boolean); } -export { Thing }; +export type { Thing }; diff --git a/tests/testcases/ts47/expected.d.ts b/tests/testcases/ts47/expected.d.ts index 9b8542f..d261242 100644 --- a/tests/testcases/ts47/expected.d.ts +++ b/tests/testcases/ts47/expected.d.ts @@ -4,4 +4,4 @@ interface State { get: () => T; set: (value: T) => void; } -export { FirstHammer, State }; +export type { FirstHammer, State }; diff --git a/tests/testcases/ts48/expected.d.ts b/tests/testcases/ts48/expected.d.ts index 32b6944..be05616 100644 --- a/tests/testcases/ts48/expected.d.ts +++ b/tests/testcases/ts48/expected.d.ts @@ -1,3 +1,3 @@ type MyNum = number; type SomeNum = "100" extends `${infer U extends MyNum}` ? U : never; -export { SomeNum }; +export type { SomeNum }; diff --git a/tests/testcases/type-conditional/expected.d.ts b/tests/testcases/type-conditional/expected.d.ts index f60e271..ec6bbac 100644 --- a/tests/testcases/type-conditional/expected.d.ts +++ b/tests/testcases/type-conditional/expected.d.ts @@ -2,4 +2,4 @@ interface A {} interface B {} interface C {} declare type Foo = A extends B ? C : never; -export { Foo }; +export type { Foo }; diff --git a/tests/testcases/type-constructor/expected.d.ts b/tests/testcases/type-constructor/expected.d.ts index 5bb3565..ec8b633 100644 --- a/tests/testcases/type-constructor/expected.d.ts +++ b/tests/testcases/type-constructor/expected.d.ts @@ -2,4 +2,4 @@ interface A {} interface B {} interface C {} declare type Foo = new (a: A, b: B) => C; -export { Foo }; +export type { Foo }; diff --git a/tests/testcases/type-function/expected.d.ts b/tests/testcases/type-function/expected.d.ts index f29cb18..cfa9dc6 100644 --- a/tests/testcases/type-function/expected.d.ts +++ b/tests/testcases/type-function/expected.d.ts @@ -2,4 +2,4 @@ interface A {} interface B {} interface C {} declare type Foo = (a: A, b: B) => C; -export { Foo }; +export type { Foo }; diff --git a/tests/testcases/type-index/expected.d.ts b/tests/testcases/type-index/expected.d.ts index c08d351..9decd84 100644 --- a/tests/testcases/type-index/expected.d.ts +++ b/tests/testcases/type-index/expected.d.ts @@ -2,4 +2,4 @@ interface A {} declare type Foo = { [k: string]: A; }; -export { Foo }; +export type { Foo }; diff --git a/tests/testcases/type-literal/expected.d.ts b/tests/testcases/type-literal/expected.d.ts index c9596d0..8b9b116 100644 --- a/tests/testcases/type-literal/expected.d.ts +++ b/tests/testcases/type-literal/expected.d.ts @@ -2,4 +2,4 @@ interface A {} declare type Foo = { a: A; }; -export { Foo }; +export type { Foo }; diff --git a/tests/testcases/type-mapped/expected.d.ts b/tests/testcases/type-mapped/expected.d.ts index 3007212..d71fccf 100644 --- a/tests/testcases/type-mapped/expected.d.ts +++ b/tests/testcases/type-mapped/expected.d.ts @@ -3,4 +3,4 @@ interface B {} declare type Foo = { [P in keyof A]: B[P]; }; -export { Foo }; +export type { Foo }; diff --git a/tests/testcases/type-simple/expected.d.ts b/tests/testcases/type-simple/expected.d.ts index d033fa2..1607a83 100644 --- a/tests/testcases/type-simple/expected.d.ts +++ b/tests/testcases/type-simple/expected.d.ts @@ -15,4 +15,4 @@ interface N { foo(): this; } declare const O: bigint; -export { A, B, C, D, E, F, G, H, I, J, K, L, M, N, O }; +export { A, B, C, D, E, F, G, H, I, J, K, L, M, type N, O }; diff --git a/tests/testcases/type-template-literals/expected.d.ts b/tests/testcases/type-template-literals/expected.d.ts index fd3a1ce..bf03373 100644 --- a/tests/testcases/type-template-literals/expected.d.ts +++ b/tests/testcases/type-template-literals/expected.d.ts @@ -4,4 +4,4 @@ type VerticalAlignment = "top" | "middle" | "bottom"; type HorizontalAlignment = "left" | "center" | "right"; type SeussFish = `${Quantity | Color} fish`; declare function setAlignment(value: `${VerticalAlignment}-${HorizontalAlignment}`): void; -export { SeussFish, setAlignment }; +export { type SeussFish, setAlignment }; diff --git a/tests/testcases/using-mts-cts-files/expected.d.ts b/tests/testcases/using-mts-cts-files/expected.d.ts index 7ce9c64..241c343 100644 --- a/tests/testcases/using-mts-cts-files/expected.d.ts +++ b/tests/testcases/using-mts-cts-files/expected.d.ts @@ -1,10 +1,10 @@ // mts.d.ts -export { A } from './main-b-124c52f0.js'; +export { A } from './main-b-0fcfb715.js'; // cts.d.ts -export { B } from './main-b-124c52f0.js'; -// main-b-124c52f0.d.ts +export { B } from './main-b-0fcfb715.js'; +// main-b-0fcfb715.d.ts interface A { } interface B { } -export { A, B }; +export type { A, B }; diff --git a/tests/testcases/using-namespace-import/expected.d.ts b/tests/testcases/using-namespace-import/expected.d.ts index b3279e7..eeae72f 100644 --- a/tests/testcases/using-namespace-import/expected.d.ts +++ b/tests/testcases/using-namespace-import/expected.d.ts @@ -2,4 +2,4 @@ interface Bar {} interface Foo { bar: Bar; } -export { Foo }; +export type { Foo }; diff --git a/tests/testcases/using-ts-files/expected.d.ts b/tests/testcases/using-ts-files/expected.d.ts index 5971092..3714fc4 100644 --- a/tests/testcases/using-ts-files/expected.d.ts +++ b/tests/testcases/using-ts-files/expected.d.ts @@ -1,10 +1,10 @@ // a.d.ts -export { A } from './main-b-124c52f0.js'; +export { A } from './main-b-0fcfb715.js'; // b.d.ts -export { B } from './main-b-124c52f0.js'; -// main-b-124c52f0.d.ts +export { B } from './main-b-0fcfb715.js'; +// main-b-0fcfb715.d.ts interface A { } interface B { } -export { A, B }; +export type { A, B }; diff --git a/tests/testcases/variadic-tuple-types/expected.d.ts b/tests/testcases/variadic-tuple-types/expected.d.ts index 9352922..3004fb7 100644 --- a/tests/testcases/variadic-tuple-types/expected.d.ts +++ b/tests/testcases/variadic-tuple-types/expected.d.ts @@ -3,4 +3,4 @@ type Numbers = [number, number]; type StrStrNumNumBool = [...Strings, ...Numbers, boolean]; type Arr = readonly any[]; declare function concat(arr1: T, arr2: U): [...T, ...U]; -export { StrStrNumNumBool, concat }; +export { type StrStrNumNumBool, concat }; From bdebf80e842850f4f769cf7feca43d416874f5a5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lucas=20Treffenst=C3=A4dt?= Date: Fri, 4 Aug 2023 13:31:30 +0200 Subject: [PATCH 3/7] raise minimum typescript version to 4.5 --- .github/workflows/ci.yml | 2 +- package-lock.json | 2 +- package.json | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index cee80f2..d678d66 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -29,6 +29,6 @@ jobs: continue-on-error: true run: bash <(curl -s https://codecov.io/bash) -t ${{secrets.CODECOV_TOKEN}} -B ${{ github.ref }} -f coverage/coverage-final.json # test the minimum supported peer dependency version - - run: npm install typescript@4.1 rollup@3.0 + - run: npm install typescript@4.5 rollup@3.0 # aka `npm test` without the `pretest/build` - run: node .build/tests/index.js diff --git a/package-lock.json b/package-lock.json index 342a3b4..53d5a2a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -33,7 +33,7 @@ }, "peerDependencies": { "rollup": "^3.0", - "typescript": "^4.1 || ^5.0" + "typescript": "^4.5 || ^5.0" } }, "node_modules/@babel/code-frame": { diff --git a/package.json b/package.json index e14e923..088b00b 100644 --- a/package.json +++ b/package.json @@ -60,7 +60,7 @@ }, "peerDependencies": { "rollup": "^3.0", - "typescript": "^4.1 || ^5.0" + "typescript": "^4.5 || ^5.0" }, "optionalDependencies": { "@babel/code-frame": "^7.22.5" From b002be218280ca2d151c136727c949ee8eeff06b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lucas=20Treffenst=C3=A4dt?= Date: Fri, 4 Aug 2023 13:31:50 +0200 Subject: [PATCH 4/7] raise minimum node.js version to 16 --- .github/workflows/ci.yml | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d678d66..6f79ca9 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -6,7 +6,7 @@ jobs: strategy: fail-fast: false matrix: - node: [14, 18] + node: [16, 18, 20] os: [ubuntu-latest, windows-latest] name: Node ${{ matrix.node }} on ${{ matrix.os }} diff --git a/package.json b/package.json index 088b00b..c61131f 100644 --- a/package.json +++ b/package.json @@ -22,7 +22,7 @@ }, "homepage": "https://github.com/Swatinem/rollup-plugin-dts#readme", "engines": { - "node": ">=v14.21.3" + "node": ">=v16.20.1" }, "type": "module", "main": "./dist/rollup-plugin-dts.cjs", From 9f9e6f6d19d9e249589d7962c98da63c976d8679 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lucas=20Treffenst=C3=A4dt?= Date: Fri, 4 Aug 2023 13:45:39 +0200 Subject: [PATCH 5/7] record changed node.js version in package-lock.json --- package-lock.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package-lock.json b/package-lock.json index 53d5a2a..46b6028 100644 --- a/package-lock.json +++ b/package-lock.json @@ -23,7 +23,7 @@ "typescript": "5.1.6" }, "engines": { - "node": ">=v14.21.3" + "node": ">=v16.20.1" }, "funding": { "url": "https://github.com/sponsors/Swatinem" From b6c0531a812a4ea3be19d9c112534499ecaa39cd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lucas=20Treffenst=C3=A4dt?= Date: Fri, 4 Aug 2023 13:48:21 +0200 Subject: [PATCH 6/7] 6.0.0 release notes --- CHANGELOG.md | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index c9fc2f8..ee5f4e9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,15 @@ # Changelog +## 6.0.0 + +**Compatibility Notice**: + +This release raises the minimum required TypeScript version to **4.5** and the minimum required node.js version to **16**. + +**Fixes**: + +- Export types with `export { type T }` syntax. + ## 5.3.1 **Fixes**: From 9ae04b88fda77e7ccb8b78d58994655b3857fb86 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lucas=20Treffenst=C3=A4dt?= Date: Fri, 4 Aug 2023 14:08:48 +0200 Subject: [PATCH 7/7] raise minimum node version to 18 --- .github/workflows/ci.yml | 4 ++-- CHANGELOG.md | 2 +- package-lock.json | 2 +- package.json | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 6f79ca9..e374ef6 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -6,7 +6,7 @@ jobs: strategy: fail-fast: false matrix: - node: [16, 18, 20] + node: [18, 20] os: [ubuntu-latest, windows-latest] name: Node ${{ matrix.node }} on ${{ matrix.os }} @@ -24,7 +24,7 @@ jobs: # frequently hangs for whatever reason, # and we have no platform-specific code anyway… - name: upload coverage - if: matrix.os == 'ubuntu-latest' && matrix.node == 18 + if: matrix.os == 'ubuntu-latest' && matrix.node == 20 timeout-minutes: 1 continue-on-error: true run: bash <(curl -s https://codecov.io/bash) -t ${{secrets.CODECOV_TOKEN}} -B ${{ github.ref }} -f coverage/coverage-final.json diff --git a/CHANGELOG.md b/CHANGELOG.md index ee5f4e9..b6ee9d7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,7 +4,7 @@ **Compatibility Notice**: -This release raises the minimum required TypeScript version to **4.5** and the minimum required node.js version to **16**. +This release raises the minimum required TypeScript version to **4.5** and the minimum required node.js version to **18**. **Fixes**: diff --git a/package-lock.json b/package-lock.json index 46b6028..981c392 100644 --- a/package-lock.json +++ b/package-lock.json @@ -23,7 +23,7 @@ "typescript": "5.1.6" }, "engines": { - "node": ">=v16.20.1" + "node": ">=v18.16.0" }, "funding": { "url": "https://github.com/sponsors/Swatinem" diff --git a/package.json b/package.json index c61131f..da1ee74 100644 --- a/package.json +++ b/package.json @@ -22,7 +22,7 @@ }, "homepage": "https://github.com/Swatinem/rollup-plugin-dts#readme", "engines": { - "node": ">=v16.20.1" + "node": ">=v18.16.0" }, "type": "module", "main": "./dist/rollup-plugin-dts.cjs",