From 75af2605d2ebaadeda5a2b73ab9cdc7787b66862 Mon Sep 17 00:00:00 2001 From: notaphplover Date: Fri, 29 Nov 2024 11:51:49 +0100 Subject: [PATCH] Workaround bundled circular referenced types (#1657) * chore: update rollup config plugin with right typescript config file * fix: add a workaround to ensure types are properly bundled * docs: update changelog --- CHANGELOG.md | 1 + rollup.config.mjs | 6 +++++- src/interfaces/interfaces.ts | 8 ++++---- src/interfaces/interfaces_common_exports.ts | 12 ++++++++++++ 4 files changed, 22 insertions(+), 5 deletions(-) create mode 100644 src/interfaces/interfaces_common_exports.ts diff --git a/CHANGELOG.md b/CHANGELOG.md index 78329f89..575a3730 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Changed ### Fixed +- Updated ESM bundled types to solve circularly referenced types. ## [6.1.5-beta.1] diff --git a/rollup.config.mjs b/rollup.config.mjs index 76b5fab9..6c8117b7 100644 --- a/rollup.config.mjs +++ b/rollup.config.mjs @@ -48,6 +48,10 @@ export default [ { input: 'lib/esm/index.d.ts', output: [{ file: 'lib/esm/index.d.ts', format: 'es' }], - plugins: [dts()], + plugins: [ + dts({ + tsconfig: './tsconfig.esm.json', + }), + ], }, ]; diff --git a/src/interfaces/interfaces.ts b/src/interfaces/interfaces.ts index e15a9b90..551c8e69 100644 --- a/src/interfaces/interfaces.ts +++ b/src/interfaces/interfaces.ts @@ -1,11 +1,11 @@ /* eslint-disable @typescript-eslint/naming-convention */ -import { - Newable as CommonNewable, - ServiceIdentifier as CommonServiceIdentifier, -} from '@inversifyjs/common'; import { LegacyTarget } from '@inversifyjs/core'; import { FactoryType } from '../utils/factory_type'; +import { + CommonNewable, + CommonServiceIdentifier, +} from './interfaces_common_exports'; // eslint-disable-next-line @typescript-eslint/no-namespace namespace interfaces { diff --git a/src/interfaces/interfaces_common_exports.ts b/src/interfaces/interfaces_common_exports.ts new file mode 100644 index 00000000..02017076 --- /dev/null +++ b/src/interfaces/interfaces_common_exports.ts @@ -0,0 +1,12 @@ +import { Newable, ServiceIdentifier } from '@inversifyjs/common'; + +// Unnecesary types to workaround https://github.com/Swatinem/rollup-plugin-dts/issues/325#issuecomment-2507540892 + +export type CommonNewable< + TInstance = unknown, + // eslint-disable-next-line @typescript-eslint/no-explicit-any + TArgs extends unknown[] = any[], +> = Newable; + +export type CommonServiceIdentifier = + ServiceIdentifier;