Skip to content

docs: cover the options and functions the JS API reference was missing - #178

Merged
floyd-soomgo merged 2 commits into
masterfrom
docs/js-api-reference-coverage
Aug 25, 2026
Merged

docs: cover the options and functions the JS API reference was missing#178
floyd-soomgo merged 2 commits into
masterfrom
docs/js-api-reference-coverage

Conversation

@floyd-soomgo

@floyd-soomgo floyd-soomgo commented Aug 25, 2026

Copy link
Copy Markdown
Member

Background

docs/api-js.md is the JS API reference. It came from upstream Microsoft CodePush and never caught up with what this fork added, so it documented 8 of CodePushOptions' 17 options.

The most consequential omission: releaseHistoryFetcher is required — an app cannot be configured without it — and the reference did not mention it exists. Six callbacks this fork added were described in the README's "4-1. Telemetry Callbacks" section but nowhere in the reference. And clearUpdates was the only one of the namespace's eight functions with no section at all, which is why the entry at the top of the file linked to an anchor that resolved to nothing.

None of this is new drift. It is what the reference has looked like since the fork started adding options.

Changes

CodePushOptions — nine entries added. releaseHistoryFetcher (required, with what it receives and must return), updateChecker (deprecated, what replaces it, and that setting it takes releaseHistoryFetcher out of the path entirely), ignoreFailedUpdates (typed never here, so accepted only by sync() — the restriction is documented rather than glossed), and the six callbacks onUpdateSuccess, onUpdateRollback, onDownloadStart, onDownloadSuccess, onSyncError, onRolloutSkipped.

SyncOptions — two entries added. ignoreFailedUpdates, documented in full here since this is where it is actually usable, and rollbackRetryOptions. The section's intro claimed the two option sets differ only in checkFrequency; that stops being true once ignoreFailedUpdates is listed, so it now names both exceptions.

codePush.clearUpdates — new section, and the link at the top of the file now points at an anchor that exists. The link's target changed from #clearupdates to #codepushclearupdates, matching the eight sibling entries; a bare #### clearUpdates heading would have resolved the old anchor but broken the naming every other function section follows.

onUpdateArchiveResult was restructured while adjacent entries were being written — it had grown into one run-on entry carrying call timing, the result's composition, fallback semantics, the observation-only guarantee and the type link.

Existing entries were not reordered. rollbackRetryOptions still sits out of alphabetical order after updateDialog's sub-list, where it already was.

Verification

Nothing checks this file automatically, which is why it drifted. The check is a survey that pulls the option names out of the typings and subtracts the ones the reference lists:

T=typings/react-native-code-push.d.ts
{ awk '/^export interface CodePushOptions/,/^}/' $T; awk '/^export interface SyncOptions/,/^}/' $T; } \
  | grep -oE '^    [a-zA-Z]+\??:' | tr -d ' ?:' | sort -u > /tmp/all.txt
awk '/^##### CodePushOptions/{c=1} c&&/^##### /&&!/CodePushOptions/{exit} c' docs/api-js.md \
  | grep -oE '^\* __[a-zA-Z]+__' | sed 's/\* __//; s/__//' | sort > /tmp/doc.txt
comm -23 /tmp/all.txt /tmp/doc.txt

Empty for both sections after these commits. Every in-page anchor was also checked against the real headings: 19 unique targets, 26 headings, none unresolved.

npm run jest 259/259 and type:cli / type:scripts / type:e2e all green — formality for a markdown change, but run. Only docs/api-js.md changed.

Note that npm run typecheck does not pass on this stack: type:src fails at src/specs/NativeCodePush.ts:4 with TS2305 on EventEmitter, which predates all of this work.

Follow-ups

  • onRolloutSkipped's type is wrong. typings/react-native-code-push.d.ts:234 declares (label: string, error: Error) => void, but src/CodePush.js:86 calls onRolloutSkipped?.(latestVersion) — one argument, and there is no error on that path at all; the release was passed over by a rollout bucket check, not by a failure. A TypeScript app reading error.message compiles and then crashes. The reference documents the runtime signature and flags the mismatch inline; fixing the type is a production change and did not belong here.
  • The survey above should be a script. Wiring it into npm run would catch the next option added without a reference entry, which is the only reason this gap grew as large as it did.

Base automatically changed from diff-patch-fallback to master August 25, 2026 11:58
`docs/api-js.md` was inherited from upstream and lists eight of the
seventeen options `CodePushOptions` carries. Among the nine it left out
is `releaseHistoryFetcher`, which is required - an app cannot be
configured without one - so the reference described a decorator that
could not be called as documented.

Add the nine entries, taking their wording from the typings and from the
README's telemetry section, which already describe them. Two carry a
constraint the type states and the prose has to repeat: `updateChecker`
is deprecated in favor of `releaseHistoryFetcher`, and
`ignoreFailedUpdates` is typed `never` here, so only `sync()` accepts
it.

`SyncOptions` was missing `ignoreFailedUpdates` and
`rollbackRetryOptions`. That section refers back to `CodePushOptions`
for the options the two share, so `rollbackRetryOptions` does the same,
and `ignoreFailedUpdates` - the one option `CodePushOptions` forbids -
is documented in full there instead. Its intro claimed the two sets
differ only in `checkFrequency`, which stopped being true once that
option is listed.

`onRolloutSkipped` is documented as the runtime calls it, with the label
alone. The typings declare a second `error` parameter that
`src/CodePush.js:86` never passes, and the entry says so rather than
promising a caller an argument it will not receive.

`onUpdateArchiveResult` was already documented, but ran its call timing,
the contents of the result, what a fallback means and the observation
guarantee together in one sentence. Split it, and let the link to the
type carry the shape the entry was restating.
`clearUpdates` was the only one of the namespace's eight functions with
no section of its own, and the entry listing it linked `#clearupdates`,
an anchor no heading in the file produced. It was the reference's only
broken in-page link.

Give it a section next to its siblings, in the order the list at the top
already puts it, with the content of the typings JSDoc: what it clears,
the deployment switch it exists for, and the warning that CodePush calls
it itself when it is needed.

The heading is `codePush.clearUpdates`, like every other function
section, so its anchor is `#codepushclearupdates` and the link had to
move with it. That also makes the entry match the eight above it, which
already point at `#codepush`-prefixed anchors. The entry carried trailing
whitespace, and the line under it held nothing else; both are cleared
while the line is being touched.
@floyd-soomgo
floyd-soomgo force-pushed the docs/js-api-reference-coverage branch from 96ab0c7 to ce410ce Compare August 25, 2026 12:03
@floyd-soomgo
floyd-soomgo merged commit f9dfe35 into master Aug 25, 2026
1 check passed
@floyd-soomgo
floyd-soomgo deleted the docs/js-api-reference-coverage branch August 25, 2026 12:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant