Skip to content
This repository was archived by the owner on Nov 4, 2026. It is now read-only.
This repository was archived by the owner on Nov 4, 2026. It is now read-only.

plugin-report README's export snippets call every real export with the wrong signature — exportAsCSV(data, 'file.csv') passes a filename where the data argument goes #5048

Closed

Description

@yinlianghui

Found while implementing #5016 (three fabricated exports in packages/plugin-report/README.md). Filed unassigned, out of that card's scope, and it is a different defect class: #5016's three names are not on the export surface at all, while every name below IS real — what is wrong is the arity and argument order of the call. The name-set check that #5016 uses cannot see this class, because each of these imports reads as REAL.

Measured on origin/main at dc9d651a2c55c10a9e4d30434e429e5fdc5ae968. Line numbers are as they will be after the PR for #5016 (they shift, the blocks do not).

The three blocks

1. README.md:229-241 — the six format exporters. Real signature (src/ReportExportEngine.ts:19,43,57,96,151):

export function exportAsCSV(report: ReportComponentSchema, data: any[], config?: ReportExportConfig): void

The README calls them as (data, filename):

await exportAsCSV(reportData, 'sales-report.csv');
await exportAsPDF(reportData, 'sales-report.pdf');
await exportAsExcel(reportData, 'sales-report.xlsx');

So reportData lands in the report parameter (the schema, which is where headers, fields and title are read from) and the filename string lands in data, which the engine iterates as rows. Two further mismatches in the same three lines: there is no filename parameter at all — the name comes from report.title / config — and all five are void, not async, so the await is inert. exportReport(format, report, data, config) at :175 takes the format FIRST, which the import list implies but no snippet shows.

2. README.md:245-253 — exportWithLiveData. Real signature (src/LiveReportExporter.ts:97) takes LiveExportOptions, in which dataSource and resource are required (:34-45):

await exportWithLiveData(reportConfig, { format: 'pdf' });   // README

Missing both required keys, so this is a compile error, not a silent misfire. The function's own doc example at :88-95 shows the correct shape.

3. README.md:249-252 — exportExcelWithFormulas. Real signature (src/LiveReportExporter.ts:161) is (report, data, options) — three parameters, with the column list inside the third. The README passes two, and spells the column key field:

await exportExcelWithFormulas(reportConfig, {
  columns: [{ field: 'total', formula: 'SUM(B2:B100)' }],
});

ExcelColumnConfig (:50-61) has no field — it is { name, header, width?, numberFormat?, formula? }, and name is what the exporter reads (row[col.name]). The formula template also uses a {ROW} placeholder the snippet's SUM(B2:B100) does not exercise; the real doc example at :139-146 shows '=B{ROW}*C{ROW}'.

Impact

Block 2 fails to compile, so a reader is stopped. Blocks 1 and 3 are worse: they type-check as written against any[]/loose params and fail at runtime or, in block 1's case, quietly export a spreadsheet built from the characters of a filename. Nothing gates a package README's API assertions today (#5016's grading note).

Recheck

grep -n "export function exportAs\|export function exportReport" packages/plugin-report/src/ReportExportEngine.ts
grep -n "export async function exportWithLiveData" -A 4 packages/plugin-report/src/LiveReportExporter.ts
grep -n "export function exportExcelWithFormulas" -A 8 packages/plugin-report/src/LiveReportExporter.ts
grep -n "interface ExcelColumnConfig" -A 12 packages/plugin-report/src/LiveReportExporter.ts

Suggested fix: rewrite the three blocks against the signatures, reusing the JSDoc examples already in LiveReportExporter.ts (they are correct). Worth pricing at the same time: whether a docs gate could type-check fenced ts/tsx blocks in package READMEs — scripts/extract-mdx-demos.mjs already does something adjacent for the docs site, and this whole family (#5002, #5010-#5016, this card) exists because nothing checks them.

Related: #5016 (the fabricated-name half of the same file, in flight), #5047 (the retired query form the same file teaches), #5002 / PR #5021 (precedent).

Activity

  1. self-assigned this
    on Aug 17, 2026
  2. yinlianghui commented on Aug 17, 2026

    @yinlianghui
    ContributorAuthor

    认领(objectui 分片 PM 直辖,批次 22 补席)—— session session_01GTRjn8xBqp75dk7kFupVRt,分支 claude/issue-5048-report-export-signatures。os-dev 席位实施,PM 只读验收。

    前置已落地:PR #5053(#5016,同文件)已 squash 落 main f331f5a8b,行号以其后的 README 为准(卡面行号即按此写)。范围钉子:只改 packages/plugin-report/README.md 三个导出示例块,按真实签名重写(exportAsCSV(report, data, config?) 族、exportWithLiveData(report, options) 必填 dataSource/resource、exportExcelWithFormulas(report, data, options) 且列键为 name、formula 用 {ROW} 占位),直接复用 LiveReportExporter.ts 里现成且正确的 JSDoc 示例;⛔ 不改任何 API、不加导出;示例块对构建产物编译自证(#5016 席的探针法),旧写法回填必须转红且错误一一对应。卡面附带的「门禁 type-check README 代码块」提案不实施 —— 它已记录在 #5043,归分诊。


    Generated by Claude Code

  3. added a commit that references this issue on Aug 23, 2026
    82a9417
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingdocumentationImprovements or additions to documentationpm:queue

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions