ref: Remove createDefinedContext utility, inline standard createContext + hooks#115544
Draft
ryan953 wants to merge 6 commits into
Draft
ref: Remove createDefinedContext utility, inline standard createContext + hooks#115544ryan953 wants to merge 6 commits into
ryan953 wants to merge 6 commits into
Conversation
…guarded hooks strict: false (hook returns T | undefined, no throw): - static/app/utils/performance/contexts/onDemandControl.tsx - static/app/utils/performance/contexts/metricsCardinality.tsx - static/app/utils/performance/contexts/metricsEnhancedPerformanceDataContext.tsx (PerformanceDataMultipleMetaContext) - static/app/views/explore/metrics/metricsFrozenContext.tsx - static/app/views/explore/logs/logsFrozenContext.tsx - static/app/views/dashboards/contexts/widgetSyncContext.tsx strict: true (default — hook throws if undefined): - static/app/utils/performance/contexts/performanceEventViewContext.tsx - static/app/utils/performance/contexts/performanceDisplayContext.tsx - static/app/utils/performance/contexts/metricsEnhancedSetting.tsx - static/app/utils/performance/contexts/metricsEnhancedPerformanceDataContext.tsx (MetricsEnhancedPerformanceDataContext) - static/app/views/explore/metrics/multiMetricsQueryParams.tsx - static/app/views/explore/metrics/metricsQueryParams.tsx - static/app/views/explore/contexts/logs/logsAutoRefreshContext.tsx - static/app/views/explore/contexts/logs/logsPageData.tsx - static/app/views/explore/logs/logsQueryParamsProvider.tsx - static/app/views/explore/queryParams/context.tsx - static/app/views/dashboards/widgetCard/dashboardsMEPContext.tsx - static/app/views/seerExplorer/contexts/llmContext.tsx
Contributor
📊 Type Coverage Diff✅ No new type safety issues introduced. Coverage: 93.51% |
Move export keyword directly onto function/const declarations instead
of using separate export {} statements.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
ryan953
commented
May 14, 2026
Comment on lines
9
to
16
| const PerformanceEventViewContext = createContext< | ||
| UsePerformanceEventViewContext | undefined | ||
| >(undefined); | ||
| PerformanceEventViewContext.displayName = 'PerformanceEventViewContext'; | ||
|
|
||
| const PerformanceEventViewProvider = PerformanceEventViewContext.Provider; | ||
|
|
||
| export {PerformanceEventViewProvider, PerformanceEventViewContext}; |
Member
Author
There was a problem hiding this comment.
@cursor move the export keyword next to the thing that is defined. don't define then export separatly.
ryan953
commented
May 14, 2026
Comment on lines
22
to
161
| @@ -155,9 +155,9 @@ export function LogsFrozenContextProvider( | |||
| return <LogsFrozenContext value={value}>{props.children}</LogsFrozenContext>; | |||
| } | |||
|
|
|||
| function useLogsFrozenContext() { | |||
| function useLogsFrozenContext(): Partial<LogsFrozenContextValue> { | |||
| // default to `LogsNotFrozen` | |||
| return _useLogsFrozenContext() ?? {}; | |||
| return useLogsFrozenContextValue() ?? {}; | |||
| } | |||
Member
Author
There was a problem hiding this comment.
@cursor can we combine useLogsFrozenContext and useLogsFrozenContextValue() so we only have one function that is exported?
Co-authored-by: Ryan Albrecht <ryan@ryanalbrecht.ca>
ryan953
commented
May 14, 2026
Co-authored-by: Ryan Albrecht <ryan@ryanalbrecht.ca>
Co-authored-by: Ryan Albrecht <ryan@ryanalbrecht.ca>
ryan953
commented
May 14, 2026
|
|
||
| const {eventView: _eventView, withStaticFilters, InteractiveTitle} = props; | ||
|
|
||
| const withBreakpoint = !isCardinalityCheckLoading && !outcome?.forceTransactionsOnly; |
Member
Author
There was a problem hiding this comment.
so amazing. outcome was already defined as outcome?: MetricDataSwitcherOutcome, so the ? didn't need to be added in this PR.
Co-authored-by: Ryan Albrecht <ryan@ryanalbrecht.ca>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.


Removes the
createDefinedContext()helper fromstatic/app/utils/performance/contexts/utils.tsxand replaces all 18 usages with standardcreateContext()calls and inline guarded hooks. The helper was a thin wrapper that hid a type lie — it castContext<T | undefined>toContext<T>, masking theundefinedcase from consumers ofstrict: falsecontexts.strict: falsecontexts now honestly type their hooks asT | undefinedSix contexts used
strict: false, meaning the hook silently returnedundefinedwithout throwing when no provider was present. The old utility cast this toT, hiding the nullability from TypeScript. These hooks now returnT | undefined, and seven downstream files were updated to handle the previously-hiddenundefined:metricsDataSwitcher.tsx,trendsWidget.tsx,table.tsx,transactionOverview/index.tsx,trendChart/index.tsx,transactionOverview/utils.tsx,onDemandControl.tsxstrict: truecontexts get a standard throw guardTwelve contexts used the default
strict: true. These now have an inlineif (context === undefined) throw new Error(...)guard in their hook, preserving the same runtime behavior with no type changes for consumers.