Skip to content

refactor(utils): migrate fields and timestamp tests from Flow to Type… - #4848

Open
bonchevskyi wants to merge 1 commit into
box:masterfrom
bonchevskyi:refactor/flow-to-ts-utils-fields
Open

bonchevskyi wants to merge 1 commit into
box:masterfrom
bonchevskyi:refactor/flow-to-ts-utils-fields

Conversation

@bonchevskyi

@bonchevskyi bonchevskyi commented Sep 18, 2026

Copy link
Copy Markdown
Contributor

Summary

This PR finishes the remaining utils migration tail on master: fields from Flow (.js) to TypeScript (.ts), plus renaming timestamp tests to TypeScript. Disjoint from other in-flight utils PRs.

Migrated utilities

  • fields

Tests migrated (impl already TypeScript)

  • timestamptimestamp.test.jstimestamp.test.ts (no change to timestamp.ts)

Components / API modules touched (consumers)

No import path changes expected. fields exports field-fetch constants and helpers (fillMissingProperties, fillUserPlaceholder, findMissingProperties, etc.) used across API/Elements code paths.

Changes

  • Converted fields.js to fields.ts and added fields.js.flow for remaining Flow importers
  • Renamed fields.test.jsfields.test.ts
  • Renamed timestamp.test.jstimestamp.test.ts

Contract

  • Declared Flow contract and runtime behavior preserved for fields (exports and helper logic unchanged relative to the previous .js source)

Related

  • Disjoint from other utils migration PRs (batch 1–6: Browser/Cache/… through Xhr, uploads, etc.)
  • After all utils branches merge, only .js.flow stubs (and optional __mocks__/performance.js) remain under src/utils/ for Flow compatibility

Summary by CodeRabbit

  • New Features

    • Added comprehensive field-selection support for folders, sidebars, previews, file versions, shared links, tasks, comments, users, activity, and uploaders.
    • Added support for archive-specific field selections.
    • Added handling for missing data and unavailable user references to improve data consistency.
  • Tests

    • Updated timestamp validation tests while preserving expected handling of invalid input.

@bonchevskyi
bonchevskyi requested a review from a team as a code owner September 18, 2026 15:03
@coderabbitai

coderabbitai Bot commented Sep 18, 2026

Copy link
Copy Markdown
Contributor

Review Change StackReview Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Advanced

Run ID: 5512abe2-9007-42ac-a76d-4395e6779e86

📥 Commits

Reviewing files that changed from the base of the PR and between a4ca178 and b9996e6.

📒 Files selected for processing (4)
  • src/utils/__tests__/fields.test.ts
  • src/utils/__tests__/timestamp.test.ts
  • src/utils/fields.js.flow
  • src/utils/fields.ts

Included review availability: Your plan provides up to 4 included reviews per hour; 0 remain after this review.


Walkthrough

The change adds exported field-selection collections and property-normalization helpers in src/utils/fields.ts. It also updates invalid timestamp test arguments with explicit number casts.

Changes

Field utilities

Layer / File(s) Summary
Field selection collections
src/utils/fields.ts
Adds field collections for folders, sidebars, previews, file versions, shared links, tasks, comments, users, activity, and uploaders, including archive variants.
Property normalization helpers
src/utils/fields.ts
Adds helpers to find missing properties, fill missing nested properties with null, and replace null user references with PLACEHOLDER_USER. Exports the collections and helpers.
Timestamp test typing
src/utils/__tests__/timestamp.test.ts
Casts invalid string inputs to number while preserving expected results of 0.

Priority: ⬇️ Low

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Refactor

Suggested reviewers: greg-in-a-box

Merge Risk: ⚪ Minimal · up to b9996

The TypeScript migration preserves the utility and test contracts with no actionable regression identified.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main changes: migrating the fields utility and timestamp tests from Flow JavaScript to TypeScript.
Description check ✅ Passed The description is complete and relevant. It explains the migration scope, renamed files, compatibility contract, affected consumers, and related work. The repository template contains only informatio…
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 2…
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create a new PR

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

I nudge each field into its place
With nulls aligned in tidy space
A placeholder guards the user trail
Archive paths now list their detail
The rabbit hops through tests with care

Comment @coderabbitai help to get the list of available commands.

@greg-in-a-box greg-in-a-box left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Review

Straightforward Flow → TypeScript migration of fields, plus renaming the timestamp tests to .ts, consistent with the other utils migration batches.

What looks good

  • Export surface matches master; field-fetch constant arrays and helper logic are preserved (function → const arrow, docs trimmed).
  • .js.flow stub via rename matches the established migration pattern for remaining Flow importers.
  • findMissingProperties / fillMissingProperties optional-param tidy (properties?:properties with default; obj?:obj with default) is type-only; runtime defaults behave the same.
  • timestamp.test.ts casts (as unknown as number) correctly exercise the non-number path of convertTimestampToSeconds under TypeScript.

Nits (non-blocking)

  • CI (lint_test_build) was still in progress at review time — worth confirming green before merge.

Verdict: Approve.

@greg-in-a-box greg-in-a-box left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Review

Mechanical Flow → TypeScript migration of fields, plus renaming the timestamp tests. Looks good to merge from a contract/behavior standpoint.

Checked

  • Field-list constants (including archive variants) match master fields.js one-for-one.
  • findMissingProperties / fillMissingProperties / fillUserPlaceholder logic and exports are unchanged.
  • fields.jsfields.js.flow keeps the full Flow copy for remaining Flow importers, consistent with the other in-flight utils migrations.
  • fields.test.js.ts is a rename-only; timestamp.test.ts only adds the casts needed for convertTimestampToSeconds(timestamp: number).

Nits (non-blocking)

  • Helpers still use Flow-era Object / Array<string>; fine for this pass, but a later cleanup could tighten to Record<string, unknown> (or a shared shape) if you want real TS value from the types.
  • as unknown as number in the timestamp invalid-input cases is clear enough; @ts-expect-error would also document intent if you prefer that style.

Approving.

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