Skip to content

Commit 7b8fc75

Browse files
authored
Fix use server diagnostics for type exports (#74256)
### What? NextJS should not throw `The "use server" file can only export async functions.` for type exports. ### Why? Because type exports are just a compile time abstraction.
1 parent 8ee79b8 commit 7b8fc75

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

packages/next/src/server/typescript/rules/server-boundary.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,11 @@ const serverBoundary = {
6464
const diagnostics: tsModule.Diagnostic[] = []
6565

6666
const exportClause = node.exportClause
67-
if (exportClause && ts.isNamedExports(exportClause)) {
67+
if (!node.isTypeOnly && exportClause && ts.isNamedExports(exportClause)) {
6868
for (const e of exportClause.elements) {
69+
if (e.isTypeOnly) {
70+
continue
71+
}
6972
if (!isFunctionReturningPromise(e, typeChecker, ts)) {
7073
diagnostics.push({
7174
file: source,

0 commit comments

Comments
 (0)