Skip to content

Commit 488175b

Browse files
committed
docs: trim redundant comments and convert render-types doc to JSDoc
Drop comments that restated adjacent JSDoc/functions: - base.tsx: the inline-handler re-subscribe rationale lived in both the `interactive` and `onEvents` comments; keep it once at `onEvents` (where the subscription happens) and point the `interactive` note at it. - use-metric-view.ts: result-branch comment re-explained metadata narrowing already documented on `asMetricMetadata`; defer to that doc. - js/format/index.ts: call-site comment restated `currencyPrefix`'s own JSDoc. - render-types.ts: convert `generateMetricTypeDeclarations`'s // block to /** */ so the exported function's rationale surfaces on IDE hover. Co-authored-by: Isaac Signed-off-by: Atila Fassina <atila@fassina.eu>
1 parent d8eac28 commit 488175b

4 files changed

Lines changed: 16 additions & 21 deletions

File tree

packages/appkit-ui/src/js/format/index.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,9 +81,6 @@ export function formatValue(value: unknown, format?: string): string {
8181
const isPercent = format.includes("%");
8282
const grouping = format.includes(",");
8383
const decimals = countDecimals(format);
84-
// Any leading symbol (before the first digit placeholder) is a currency
85-
// prefix — emit it verbatim so non-USD symbols the generator produces are
86-
// preserved instead of collapsing to "$".
8784
const prefix = currencyPrefix(format);
8885

8986
// bigint fast path. A bigint is an exact integer, so `BigInt.toLocaleString`

packages/appkit-ui/src/react/charts/base.tsx

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -233,11 +233,10 @@ export function BaseChart({
233233
const ui = useChartUITokens();
234234

235235
// Only the *presence* of a click handler shapes the option (it flips
236-
// `triggerLineEvent`/`symbolSize` on line/area) AND the `onEvents` map below.
237-
// Depend on this boolean, not the handler reference — consumers pass an inline
238-
// `onDataClick`, whose identity changes every render, so depending on the
239-
// reference would rebuild the whole option object AND re-subscribe the ECharts
240-
// click listener on every parent re-render (e.g. each SSE tick).
236+
// `triggerLineEvent`/`symbolSize` on line/area) AND gates the `onEvents` map
237+
// below. Depend on this boolean, not the handler reference, so an inline
238+
// `onDataClick` (new identity every render) doesn't rebuild the option object
239+
// each render — see `onEvents` for the matching subscription rationale.
241240
const interactive = !!onDataClick;
242241

243242
// Keep the latest handler in a ref so `onEvents` can call the current

packages/appkit-ui/src/react/hooks/use-metric-view.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -98,10 +98,7 @@ function handleMetricSseMessage(
9898
// optional array of unknown values), so a shallow structural check is enough
9999
// here rather than a full schema validator. Missing or non-array `data`
100100
// normalizes to [] so `undefined` never bleeds into the hook's `T | null`
101-
// state. `metadata` (per-column display metadata scoped to the queried
102-
// columns) is surfaced as-is only when it is a plain object; anything else
103-
// (null / array / scalar) is treated as absent. It is `undefined` when the
104-
// server injected none (dormant / unknown key).
101+
// state. `metadata` is narrowed by `asMetricMetadata` (see its doc).
105102
if (parsed.type === "result") {
106103
ctx.setLoading(false);
107104
// A successful result supersedes any error from a prior (retried) attempt —

packages/appkit/src/type-generator/mv-registry/render-types.ts

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -236,15 +236,17 @@ ${entries};
236236
`;
237237
}
238238

239-
// Build the full metric-views.ts file from a list of metric schemas.
240-
//
241-
// This is a real `.ts` source file (not a `.d.ts`), so it carries BOTH the
242-
// erasable `declare module` type augmentation AND a runtime value export
243-
// (`metricViewsMetadata`). It must therefore never emit a runtime side-effect
244-
// import — a bare `import "@databricks/appkit-ui/react"` would execute the
245-
// client package entry on the Node server. The header is a type-only
246-
// `import type {} from "..."`, which (a) compiles to zero runtime code and
247-
// (b) anchors the module so the global `declare module` augmentation resolves.
239+
/**
240+
* Build the full metric-views.ts file from a list of metric schemas.
241+
*
242+
* This is a real `.ts` source file (not a `.d.ts`), so it carries BOTH the
243+
* erasable `declare module` type augmentation AND a runtime value export
244+
* (`metricViewsMetadata`). It must therefore never emit a runtime side-effect
245+
* import — a bare `import "@databricks/appkit-ui/react"` would execute the
246+
* client package entry on the Node server. The header is a type-only
247+
* `import type {} from "..."`, which (a) compiles to zero runtime code and
248+
* (b) anchors the module so the global `declare module` augmentation resolves.
249+
*/
248250
export function generateMetricTypeDeclarations(
249251
schemas: MetricSchema[],
250252
): string {

0 commit comments

Comments
 (0)