Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions packages/base-controller/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

### Fixed

- Fix TypeScript module resolution for `/next` subpath export with legacy resolution mode ([#6915](https://github.com/MetaMask/core/pull/6915))
- Added `next.d.ts` file to enable imports like `import { BaseController } from '@metamask/base-controller/next'` to work with both legacy TypeScript module resolution and Node16/NodeNext resolution modes
- Previously, this import pattern only worked with Node16/NodeNext resolution which uses the `exports` field in package.json

## [8.4.1]

### Changed
Expand Down
7 changes: 7 additions & 0 deletions packages/base-controller/next.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
// Type definitions for compatibility with legacy TypeScript module resolution.
// Node16/NodeNext resolution uses the "exports" field in package.json,
// but legacy resolution needs explicit .d.ts files at the import path.

// Re-export all types and values from the CommonJS build
// eslint-disable-next-line import-x/no-useless-path-segments, import-x/extensions
export * from './dist/next/index.cjs';
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: TypeScript Re-export Issue

The next.d.ts file re-exports from ./dist/next/index.cjs, a JavaScript file, instead of its corresponding TypeScript declaration file (./dist/next/index.d.cts). This prevents proper type resolution for consumers using legacy module resolution.

Fix in Cursor Fix in Web

3 changes: 2 additions & 1 deletion packages/base-controller/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@
"types": "./dist/index.d.cts",
"files": [
"dist/",
"next.js"
"next.js",
"next.d.ts"
],
"scripts": {
"build": "ts-bridge --project tsconfig.build.json --verbose --clean --no-references",
Expand Down
Loading