Skip to content

TypeCheck Frontend#2394

Open
samfreund wants to merge 24 commits intoPhotonVision:2027from
samfreund:vue-tsc
Open

TypeCheck Frontend#2394
samfreund wants to merge 24 commits intoPhotonVision:2027from
samfreund:vue-tsc

Conversation

@samfreund
Copy link
Copy Markdown
Member

@samfreund samfreund commented Mar 11, 2026

Description

We recently had an error that would've been caught by type checking in the frontend (see #2393). This PR implements type checking so that future errors will be caught.

Additionally, this PR contains miscellaneous frontend cleanup that's tangentially related to type-checking.

Meta

Merge checklist:

  • Pull Request title is short, imperative summary of proposed changes
  • The description documents the what and why, including events that led to this PR
  • If this PR changes behavior or adds a feature, user documentation is updated
  • If this PR touches photon-serde, all messages have been regenerated and hashes have not changed unexpectedly
  • If this PR touches configuration, this is backwards compatible with all settings going back to the previous seasons's last release (seasons end after champs ends)
  • If this PR touches pipeline settings or anything related to data exchange, the frontend typing is updated
  • If this PR addresses a bug, a regression test for it is added
  • If this PR adds a dependency, the license has been checked for compatibility and steps taken to follow it

@samfreund samfreund requested a review from a team as a code owner March 11, 2026 05:27
@github-actions github-actions bot added the frontend Having to do with PhotonClient and its related items label Mar 11, 2026
@samfreund samfreund force-pushed the vue-tsc branch 5 times, most recently from aa75092 to f72c9b7 Compare March 11, 2026 05:39
@samfreund samfreund marked this pull request as draft March 11, 2026 05:44
@samfreund
Copy link
Copy Markdown
Member Author

Grrrr, type checking didn't type check (error was introduced and uncaught)

Copy link
Copy Markdown
Contributor

@Gold856 Gold856 left a comment

Choose a reason for hiding this comment

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

Too much use of as. Try using https://vuejs.org/api/sfc-script-setup.html#generics to fix most of the instances where you need as. We need to ensure the types are actually correct, not just promise that it's correct.

@github-actions github-actions bot added the backend Things relating to photon-core and photon-server label Mar 11, 2026
@samfreund samfreund force-pushed the vue-tsc branch 2 times, most recently from c839cfe to 97a298a Compare March 11, 2026 18:39
@github-actions github-actions bot removed the backend Things relating to photon-core and photon-server label Mar 11, 2026
@samfreund samfreund force-pushed the vue-tsc branch 2 times, most recently from 05925d7 to 473ea67 Compare March 23, 2026 19:34
@samfreund samfreund requested a review from Gold856 March 23, 2026 19:35
@samfreund samfreund force-pushed the vue-tsc branch 2 times, most recently from d42f4ae to 46f6355 Compare March 23, 2026 19:45
@Gold856 Gold856 mentioned this pull request Mar 23, 2026
8 tasks
Gold856 added a commit that referenced this pull request Mar 23, 2026
As a precursor to #2394, add a bunch of linting rules to try and catch
more mistakes/potential code errors/unnecessary code. Add a bunch of
rules from https://eslint.vuejs.org/rules/ in the "uncategorized"
section that seem useful to have.
@samfreund samfreund force-pushed the vue-tsc branch 4 times, most recently from 277324b to ede1ca7 Compare March 24, 2026 00:48
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 42 out of 44 changed files in this pull request and generated 2 comments.

Files not reviewed (1)
  • photon-client/pnpm-lock.yaml: Language not supported
Comments suppressed due to low confidence (1)

photon-client/src/components/common/pv-select.vue:60

  • SelectItem includes an optional disabled field, and some call sites populate it (e.g. to disable rotations for CSI cameras). However pv-select doesn't pass item-level disabled state through to v-select, so those options can still be selected. Wire SelectItem.disabled into Vuetify's item props (e.g. via item-props / item-disabled support) so disabled items are actually non-selectable.
export interface SelectItem<TValue extends string | number> {
  name: string | number;
  value: TValue;
  disabled?: boolean;
}

type SelectItems = SelectItem<T>[] | ReadonlyArray<T>;
const value = defineModel<T>({ required: true });

const props = withDefaults(
  defineProps<{
    label?: string;
    tooltip?: string;
    selectCols?: number;
    disabled?: boolean;
    items: SelectItems;
  }>(),
  {
    selectCols: 9,
    disabled: false
  }
);

const areSelectItems = (items: SelectItems): items is SelectItem<T>[] => typeof items[0] === "object";

// Computed in case items changes
const items = computed<SelectItem<T>[]>(() => {
  // Trivial case for empty list; we have no data
  if (!props.items.length) {
    return [];
  }

  if (areSelectItems(props.items)) {
    return props.items;
  }

  return props.items.map((item) => ({ name: item, value: item }));
});
</script>

<template>
  <div class="d-flex">
    <v-col :cols="12 - selectCols" class="d-flex align-center pl-0 pt-10px pb-10px">
      <tooltipped-label :tooltip="tooltip" :label="label" />
    </v-col>
    <v-col :cols="selectCols" class="d-flex align-center pr-0 pt-10px pb-10px">
      <v-select
        v-model="value"
        :items="items"
        item-title="name"
        item-value="value"
        :disabled="disabled"
        hide-details="auto"
        variant="underlined"
        density="compact"
      />

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

SpeedSlicer pushed a commit to SpeedSlicer/photonvision that referenced this pull request Mar 30, 2026
As a precursor to PhotonVision#2394, add a bunch of linting rules to try and catch
more mistakes/potential code errors/unnecessary code. Add a bunch of
rules from https://eslint.vuejs.org/rules/ in the "uncategorized"
section that seem useful to have.
@samfreund samfreund changed the base branch from main to 2027 April 4, 2026 22:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

frontend Having to do with PhotonClient and its related items

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants