Skip to content

Types for @wordpress/preferences cannot be resolved when using "exports" #73275

@chihsuan

Description

@chihsuan

Description

@wordpress/preferences package ships type definitions under build-types folder, but hese are not exposed in package.json "exports", which causes TypeScript resolution errors such

There are types at node_modules/@wordpress/preferences/build-types/index.d.ts,
but this result could not be resolved when respecting package.json "exports".
The @wordpress/preferences library may need to update its package.json or typings.

Because the package defines an "exports" field, Node and TypeScript treat any unlisted paths as private and the types folder is not exported.

"exports": {
".": {
"import": "./build-module/index.js",
"require": "./build/index.js"
},
"./package.json": "./package.json",
"./build-style/": "./build-style/"
},

Additional Notes

This issue affects projects using strict "moduleResolution": "node16" / "bundler" (Next.js, Vite, modern TS).

Metadata

Metadata

Assignees

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions