fix(types): fix TypeScript errors in SqlLab actions and AnnotationLayer

SqlLab actions:
- Use `as const` for action creators to preserve literal types
- Allows proper type inference for ReturnType<typeof action>
- Fixes errors in src/core/sqlLab/index.ts which uses ReturnType

AnnotationLayer:
- Handle possibly undefined props in constructor
- Create processedOverrides to avoid mutating undefined
- Add default values for all optional state properties

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
Evan Rusackas
2025-12-19 00:19:16 -08:00
parent 6a4608d3a9
commit c9b0d8d5af
2 changed files with 29 additions and 34 deletions

View File

@@ -204,10 +204,11 @@ class AnnotationLayer extends PureComponent<
} = props;
// Only allow override whole time_range
if ('since' in overrides || 'until' in overrides) {
overrides.time_range = null;
delete overrides.since;
delete overrides.until;
const processedOverrides: AnnotationOverrides = overrides ? { ...overrides } : {};
if ('since' in processedOverrides || 'until' in processedOverrides) {
processedOverrides.time_range = null;
delete processedOverrides.since;
delete processedOverrides.until;
}
// Check if annotationType is supported by this chart
@@ -221,25 +222,25 @@ class AnnotationLayer extends PureComponent<
this.state = {
// base
name,
annotationType: validAnnotationType,
sourceType,
value,
overrides,
show,
showLabel,
name: name || '',
annotationType: validAnnotationType || DEFAULT_ANNOTATION_TYPE,
sourceType: sourceType || null,
value: value || null,
overrides: processedOverrides,
show: show ?? true,
showLabel: showLabel ?? false,
// slice
titleColumn,
descriptionColumns,
timeColumn,
intervalEndColumn,
titleColumn: titleColumn || '',
descriptionColumns: descriptionColumns || [],
timeColumn: timeColumn || '',
intervalEndColumn: intervalEndColumn || '',
// display
color: color || AUTOMATIC_COLOR,
opacity,
style,
width,
showMarkers,
hideLine,
opacity: opacity || '',
style: style || 'solid',
width: width ?? 1,
showMarkers: showMarkers ?? false,
hideLine: hideLine ?? false,
// refData
isNew: !name,
slice: null,