Skip to content

ref(types): define IntervalPeriod without importing charts/utils#116853

Open
JoshuaKGoldberg wants to merge 8 commits into
masterfrom
ref/decycle-interval-period
Open

ref(types): define IntervalPeriod without importing charts/utils#116853
JoshuaKGoldberg wants to merge 8 commits into
masterfrom
ref/decycle-interval-period

Conversation

@JoshuaKGoldberg
Copy link
Copy Markdown
Member

@JoshuaKGoldberg JoshuaKGoldberg commented Jun 4, 2026

Why

Part of the series shrinking the frontend's largest type-import strongly-connected component (SCC). Identified via a greedy independent-cut analysis of the import graph.

types/core is a foundational types module (imported by ~155 other SCC members), but it was dragged into the cycle by a single edge: it imported getInterval from sentry/components/charts/utils only to write export type IntervalPeriod = ReturnType<typeof getInterval>.

What

getInterval's declared return type is string (its fidelity ladder's getInterval(minutes: number): string), so IntervalPeriod is already exactly string. Define it directly and drop the import.

Impact

Largest import SCC: 1697 → 1680 (−17).

JoshuaKGoldberg and others added 4 commits June 3, 2026 16:05
`overlay` and `useHoverOverlay` were pulled into the frontend type-import
strongly-connected component (SCC) solely by value-imports from the
`sentry/constants` and `sentry/utils` god-barrels:

- `NODE_ENV` now comes from the `sentry/constants/env` leaf
- `defined` is extracted to a `sentry/utils/defined` leaf (the `sentry/utils`
  barrel re-exports it, so existing consumers are untouched)

With those two modules out of the cycle, `core/tooltip` — one of the most
widely-imported core components — and its dependents leave the SCC too.
Largest SCC drops 1867 -> 1770.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…-tooltip

# Conflicts:
#	static/app/utils.tsx
getInterval returns string, so IntervalPeriod is equivalent to a plain
string. Importing it pulled the foundational types/core module into the
frontend import cycle; defining the alias directly removes that edge.
@github-actions github-actions Bot added the Scope: Frontend Automatically applied to PRs that change frontend components label Jun 4, 2026
Base automatically changed from ref/decycle-overlay-tooltip to master June 4, 2026 17:44
Rather than hardcoding `IntervalPeriod = string` in the foundational
`types/core` module, relocate the type to `organizationStats/types`,
where all four of its consumers live. It is purely an organizationStats
usage-stats concept and was never used elsewhere.

Living there, it can keep `ReturnType<typeof getInterval>` cycle-free,
since organizationStats already depends on `charts/utils`. Core sheds
the type entirely instead of just swapping the import for a hardcoded
`string`.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@JoshuaKGoldberg JoshuaKGoldberg marked this pull request as ready for review June 4, 2026 22:59
@JoshuaKGoldberg JoshuaKGoldberg requested a review from a team as a code owner June 4, 2026 22:59
…l-period

# Conflicts:
#	static/app/types/core.tsx
#	static/app/views/organizationStats/usageChart/index.tsx
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Scope: Frontend Automatically applied to PRs that change frontend components

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant