TypeCheck Frontend#2394
Conversation
aa75092 to
f72c9b7
Compare
|
Grrrr, type checking didn't type check (error was introduced and uncaught) |
Gold856
left a comment
There was a problem hiding this comment.
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.
c839cfe to
97a298a
Compare
05925d7 to
473ea67
Compare
d42f4ae to
46f6355
Compare
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.
277324b to
ede1ca7
Compare
There was a problem hiding this comment.
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
SelectItemincludes an optionaldisabledfield, and some call sites populate it (e.g. to disable rotations for CSI cameras). Howeverpv-selectdoesn't pass item-level disabled state through tov-select, so those options can still be selected. WireSelectItem.disabledinto Vuetify's item props (e.g. viaitem-props/item-disabledsupport) 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.
c3022e2 to
e9120e9
Compare
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.
0e3f170 to
37bbcd6
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 42 out of 44 changed files in this pull request and generated 3 comments.
Files not reviewed (1)
- photon-client/pnpm-lock.yaml: Language not supported
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This comment was marked as resolved.
This comment was marked as resolved.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 41 out of 43 changed files in this pull request and generated 3 comments.
Files not reviewed (1)
- photon-client/pnpm-lock.yaml: Language not supported
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 41 out of 43 changed files in this pull request and generated 4 comments.
Files not reviewed (1)
- photon-client/pnpm-lock.yaml: Language not supported
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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: