Skip to content

Core: convert src/utils.js to typescript (preparation) - #1

Draft
derdeka wants to merge 12 commits into
masterfrom
refactor/20260513_src-utils-to-ts
Draft

derdeka wants to merge 12 commits into
masterfrom
refactor/20260513_src-utils-to-ts

Conversation

@derdeka

@derdeka derdeka commented Nov 9, 2026

Copy link
Copy Markdown
Owner

ABOUT

  • prepare src/utils.js typescript migration

@derdeka derdeka self-assigned this Nov 9, 2026
@derdeka
derdeka requested a balanced review from Copilot November 9, 2026 10:52

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The new TypeScript declarations conflict with existing runtime behavior and supported APIs, including non-string return values, nullable bidders, numeric-string sizes, and constructor usage.

1 open issue
What changed in this PR

Prepares the core utility layer for TypeScript migration by adding explicit contracts and updating dependent code.

Changes:

  • Adds parameter, return, and generic types throughout src/utils.ts and related helpers.
  • Migrates CachedApiWrapper to TypeScript and adds browser API declarations.
  • Updates rendering, bidder partitioning, and adapter types to accommodate the utility signatures.
File Description
src/​utils/​winDimensions.ts Defines window dimension and orientation types.
src/​utils/​reducers.ts Types generic comparators and bid reducers.
src/​utils/​objects.ts Annotates validation inputs and type guards.
src/​utils/​ipUtils.ts Types IP inputs, results, and masks.
src/​utils/​gdpr.ts Defines the consent helper’s input shape.
src/​utils/​focusTimeout.ts Types suspended callbacks and timer handles.
src/​utils/​cpm.ts Adds bid adjustment function signatures.
src/​utils/​cachedApiWrapper.ts Adds the TypeScript cache-wrapper implementation.
src/​utils/​cachedApiWrapper.js Removes the replaced JavaScript implementation.
src/​utils.ts Adds utility contracts and type-compatible expressions.
src/​types/​local/​scheduler.d.ts Declares the browser scheduling API.
src/​types/​local/​safeframe.d.ts Declares SafeFrame browser interfaces.
src/​adRendering.ts Preserves bid subtype information during rendering preparation.
src/​adapterManager.ts Types partition constants and bidder collections.
modules/​multibid/​index.ts Types received bids in the targeting hook.
modules/​asterioBidAdapter.ts Extends server response fields.
modules/​ad_spiroBidAdapter.ts Adds an OpenRTB response type assertion.

Review effort: Balanced

Comment thread src/utils/cachedApiWrapper.ts Outdated
* Wraps the properties of the object returned by `getTarget` flagged in `props` with getters that
* read through to the target once, and serve the cached value until `reset()` is called.
*/
export function CachedApiWrapper<T = any>(this: { obj: T; reset: () => void }, getTarget: () => any, props: CachedApiProps) {
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.

2 participants