Unverified Commit 7b8fc758 authored by Randolf J.'s avatar Randolf J. Committed by GitHub

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.
parent 8ee79b82
...@@ -64,8 +64,11 @@ const serverBoundary = { ...@@ -64,8 +64,11 @@ const serverBoundary = {
const diagnostics: tsModule.Diagnostic[] = [] const diagnostics: tsModule.Diagnostic[] = []
const exportClause = node.exportClause const exportClause = node.exportClause
if (exportClause && ts.isNamedExports(exportClause)) { if (!node.isTypeOnly && exportClause && ts.isNamedExports(exportClause)) {
for (const e of exportClause.elements) { for (const e of exportClause.elements) {
if (e.isTypeOnly) {
continue
}
if (!isFunctionReturningPromise(e, typeChecker, ts)) { if (!isFunctionReturningPromise(e, typeChecker, ts)) {
diagnostics.push({ diagnostics.push({
file: source, file: source,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment