Skip to content

Commit 6c81355

Browse files
fix: add type declarations for css export (TypeScript 6 compat) (#16348)
### What? Add TypeScript type declarations for the `./css` package export in `@payloadcms/next`. ### Why? TypeScript 6 enables [`noUncheckedSideEffectImports`](https://www.typescriptlang.org/tsconfig/noUncheckedSideEffectImports.html) by default. This causes `import '@payloadcms/next/css'` — present in all three files generated by `create-payload-app` — to fail with: error TS2882: Cannot find module or type declarations for side-effect import of '@payloadcms/next/css'. The published `./css` export currently has no `types` field: ```json "./css": { "import": "./dist/prod/styles.css", "default": "./dist/prod/styles.css" } ``` ### How? Add src/exports/css.ts as a regular TypeScript source file (consistent with all other exports so the existing build pipeline produces dist/exports/css.d.ts. Then wire the types field into both dev and publishConfig exports. **Testing:** Tested locally by copying the new files `cp ../../payload/packages/next/dist/exports/css.* node_modules/@payloadcms/next/dist/exports` and pacthing the package.json manually: ``` --- original-package.json 2026-04-22 10:43:26 +++ package.json 2026-04-22 10:43:57 @@ -24,6 +24,7 @@ "exports": { "./css": { "import": "./dist/prod/styles.css", + "types": "./dist/exports/css.d.ts", "default": "./dist/prod/styles.css" }, "./withPayload": { ``` after that my test project builds fine with typescript 6.0.3 Fixes #16346
1 parent ac46214 commit 6c81355

2 files changed

Lines changed: 4 additions & 0 deletions

File tree

packages/next/package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
"type": "module",
2424
"exports": {
2525
"./css": {
26+
"types": "./src/exports/css.ts",
2627
"import": "./src/dummy.css",
2728
"default": "./src/dummy.css"
2829
},
@@ -153,6 +154,7 @@
153154
"publishConfig": {
154155
"exports": {
155156
"./css": {
157+
"types": "./dist/exports/css.d.ts",
156158
"import": "./dist/prod/styles.css",
157159
"default": "./dist/prod/styles.css"
158160
},

packages/next/src/exports/css.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
const styles: void = undefined
2+
export default styles

0 commit comments

Comments
 (0)