Skip to content

Commit

Permalink
Workaround bundled circular referenced types (#1657)
Browse files Browse the repository at this point in the history
* chore: update rollup config plugin with right typescript config file

* fix: add a workaround to ensure types are properly bundled

* docs: update changelog
  • Loading branch information
notaphplover authored Nov 29, 2024
1 parent f642bee commit 75af260
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 5 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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]

Expand Down
6 changes: 5 additions & 1 deletion rollup.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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',
}),
],
},
];
8 changes: 4 additions & 4 deletions src/interfaces/interfaces.ts
Original file line number Diff line number Diff line change
@@ -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 {
Expand Down
12 changes: 12 additions & 0 deletions src/interfaces/interfaces_common_exports.ts
Original file line number Diff line number Diff line change
@@ -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<TInstance, TArgs>;

export type CommonServiceIdentifier<TInstance = unknown> =
ServiceIdentifier<TInstance>;

0 comments on commit 75af260

Please sign in to comment.