Skip to content

refactor!: use native private class fields and remove underscore prefixes - #699

Open
B4nan wants to merge 3 commits into
v4from
claude/native-private-props
Open

refactor!: use native private class fields and remove underscore prefixes#699
B4nan wants to merge 3 commits into
v4from
claude/native-private-props

Conversation

@B4nan

@B4nan B4nan commented Aug 21, 2026

Copy link
Copy Markdown
Member

Applies the same convention that landed in crawlee v4 (apify/crawlee#3980, apify/crawlee#3108) to the SDK: native # private fields for private class properties, no _ prefixes on members.

  • 52 private properties across Actor, ChargingManager, ProxyConfiguration, the storage/request-queue backends, PlatformEventManager and AsyncLock are now native # fields (hard-private at runtime, invisible to enumeration and JSON.stringify). Private and protected methods keep their keyword and lose the _ prefix; six private constructor parameter properties became explicit # fields.
  • ProxyConfiguration protected helpers renamed: _getUsernamegetUsername, _checkAccesscheckAccess, _fetchStatusfetchStatus, _requestStatusrequestStatus, _throwCannotCombineCustomWithApifythrowCannotCombineCustomWithApify. _setPasswordIfToken is now private (honoring its TODO). _throwCannotCombineCustomMethods is deleted: the crawlee base-class constructor already performs the identical check with the same message, so the SDK copy was unreachable.
  • Actor._instance (public @internal static) is now static #instance, with an @internal Actor.setDefaultInstance() seam replacing the test helpers' delete-based resets.
  • Tests that poked ProxyConfiguration's private fields via @ts-expect-error now assert through the public newProxyInfo() result; the token-fetched password path gained an assertion it previously lacked.
  • A no-underscore-dangle oxlint rule (class fields + method names) enforces the convention; the upgrading guide documents the renames and the # semantics change.

The methods stay on the prototype deliberately: the test harness routes Actor methods through crawlee's bindMethodsToServiceLocator, which only wraps prototype members.

B4nan added 3 commits August 21, 2026 16:58
…ixes

Private class properties now use native `#` fields instead of TypeScript's
compile-time `private`; private/protected methods keep their keyword and
lose the `_` prefix. `Actor.#instance` gets an @internal
`setDefaultInstance()` seam replacing the test-only `_instance` pokes,
and the dead `_throwCannotCombineCustomMethods` duplicate of the crawlee
base-class check is removed.

BREAKING CHANGE: protected ProxyConfiguration helpers were renamed
(`_getUsername` -> `getUsername`, `_checkAccess` -> `checkAccess`,
`_fetchStatus` -> `fetchStatus`, `_requestStatus` -> `requestStatus`,
`_throwCannotCombineCustomWithApify` -> `throwCannotCombineCustomWithApify`),
`_setPasswordIfToken` is now private, and private properties are no
longer reachable at runtime.
@B4nan
B4nan requested a review from szaganek as a code owner August 21, 2026 15:04
@B4nan B4nan added adhoc Ad-hoc unplanned task added during the sprint. t-tooling Issues with this label are in the ownership of the tooling team. labels Aug 21, 2026
@github-actions

Copy link
Copy Markdown

⚠️ There are broken links in the documentation.

See more at https://github.com/apify/apify-sdk-js/actions/runs/32495575482#summary-96813046532

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

adhoc Ad-hoc unplanned task added during the sprint. t-tooling Issues with this label are in the ownership of the tooling team.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants