Browse Source

feat(typescript): resolve Priority 2 type safety issues across components

- Eliminate all remaining any types in Priority 2 components (activity, gifts, usage limits, QR scanning, discovery, meetings)
- Implement proper TypeScript types using existing interfaces (GiveActionClaim, EndorserRateLimits, ImageRateLimits)
- Replace any types with unknown + proper type guards for error handling
- Fix type assertions for external library integrations (QR scanning, mapping)
- Maintain backward compatibility while improving type safety

Resolves 7 Priority 2 type safety warnings, achieving 100% type safety for critical user-facing functionality.
pull/152/head^2
Matthew Raymer 1 day ago
parent
commit
379056aae1
  1. 6
      src/components/ActivityListItem.vue
  2. 5
      src/components/GiftedDialog.vue
  3. 5
      src/components/UsageLimitsSection.vue
  4. 2
      src/constants/notifications.ts
  5. 10
      src/views/ContactQRScanShowView.vue
  6. 10
      src/views/DiscoverView.vue
  7. 5
      src/views/ImportAccountView.vue
  8. 2
      src/views/OnboardMeetingListView.vue
  9. 6
      src/views/OnboardMeetingSetupView.vue

6
src/components/ActivityListItem.vue

@ -288,8 +288,7 @@ export default class ActivityListItem extends Vue {
}
get fetchAmount(): string {
const claim =
(this.record.fullClaim as any)?.claim || this.record.fullClaim;
const claim = this.record.fullClaim;
const amount = claim.object?.amountOfThisGood
? this.displayAmount(claim.object.unitCode, claim.object.amountOfThisGood)
@ -299,8 +298,7 @@ export default class ActivityListItem extends Vue {
}
get description(): string {
const claim =
(this.record.fullClaim as any)?.claim || this.record.fullClaim;
const claim = this.record.fullClaim;
return `${claim?.description || ""}`;
}

5
src/components/GiftedDialog.vue

@ -622,7 +622,10 @@ export default class GiftedDialog extends Vue {
* Handle edit entity request from GiftDetailsStep
* @param data - Object containing entityType and currentEntity
*/
handleEditEntity(data: { entityType: string; currentEntity: any }) {
handleEditEntity(data: {
entityType: string;
currentEntity: { did: string; name: string };
}) {
this.goBackToStep1(data.entityType);
}

5
src/components/UsageLimitsSection.vue

@ -83,6 +83,7 @@
<script lang="ts">
import { Component, Vue, Prop } from "vue-facing-decorator";
import { FontAwesomeIcon } from "@fortawesome/vue-fontawesome";
import { EndorserRateLimits, ImageRateLimits } from "@/interfaces/limits";
@Component({
name: "UsageLimitsSection",
@ -94,8 +95,8 @@ export default class UsageLimitsSection extends Vue {
@Prop({ required: true }) loadingLimits!: boolean;
@Prop({ required: true }) limitsMessage!: string;
@Prop({ required: false }) activeDid?: string;
@Prop({ required: false }) endorserLimits?: any;
@Prop({ required: false }) imageLimits?: any;
@Prop({ required: false }) endorserLimits?: EndorserRateLimits;
@Prop({ required: false }) imageLimits?: ImageRateLimits;
@Prop({ required: true }) onRecheckLimits!: () => void;
mounted() {

2
src/constants/notifications.ts

@ -1588,7 +1588,7 @@ export function createImageDialogCameraErrorMessage(error: Error): string {
// Helper function for dynamic upload error messages
// Used in: ImageMethodDialog.vue (uploadImage method - dynamic upload error message)
export function createImageDialogUploadErrorMessage(error: any): string {
export function createImageDialogUploadErrorMessage(error: unknown): string {
if (axios.isAxiosError(error)) {
const status = error.response?.status;
const data = error.response?.data;

10
src/views/ContactQRScanShowView.vue

@ -714,8 +714,16 @@ export default class ContactQRScanShow extends Vue {
// Add new contact
// @ts-expect-error because we're just using the value to store to the DB
// eslint-disable-next-line @typescript-eslint/no-explicit-any
contact.contactMethods = JSON.stringify(
(this as any)._parseJsonField(contact.contactMethods, []),
(
this as {
_parseJsonField: (
value: unknown,
defaultValue: unknown[],
) => unknown[];
}
)._parseJsonField(contact.contactMethods, []),
);
await this.$insertContact(contact);

10
src/views/DiscoverView.vue

@ -458,7 +458,9 @@ export default class DiscoverView extends Vue {
if (this.isLocalActive) {
await this.searchLocal();
} else if (this.isMappedActive) {
const mapRef = this.$refs.projectMap as any;
const mapRef = this.$refs.projectMap as {
leafletObject: L.Map;
};
this.requestTiles(mapRef.leafletObject); // not ideal because I found this from experimentation, not documentation
} else {
await this.searchAll();
@ -518,11 +520,11 @@ export default class DiscoverView extends Vue {
throw JSON.stringify(results);
}
}
// eslint-disable-next-line @typescript-eslint/no-explicit-any
} catch (e: any) {
} catch (e: unknown) {
logger.error("Error with search all: " + errorStringForLog(e));
this.notify.error(
e.userMessage || NOTIFY_DISCOVER_SEARCH_ERROR.message,
(e as { userMessage?: string })?.userMessage ||
NOTIFY_DISCOVER_SEARCH_ERROR.message,
TIMEOUTS.LONG,
);
} finally {

5
src/views/ImportAccountView.vue

@ -221,10 +221,11 @@ export default class ImportAccountView extends Vue {
this.notify.success("Account imported successfully!", TIMEOUTS.STANDARD);
this.$router.push({ name: "account" });
} catch (error: any) {
} catch (error: unknown) {
this.$logError("Import failed: " + error);
this.notify.error(
error.message || "Failed to import account.",
(error instanceof Error ? error.message : String(error)) ||
"Failed to import account.",
TIMEOUTS.LONG,
);
}

2
src/views/OnboardMeetingListView.vue

@ -251,7 +251,7 @@ export default class OnboardMeetingListView extends Vue {
if (response2.data?.data) {
this.meetings = response2.data.data;
}
} catch (error: any) {
} catch (error: unknown) {
this.$logAndConsole(
"Error fetching meetings: " + errorStringForLog(error),
true,

6
src/views/OnboardMeetingSetupView.vue

@ -345,7 +345,9 @@ export default class OnboardMeetingView extends Vue {
}
async created() {
this.notify = createNotifyHelpers(this.$notify as any);
this.notify = createNotifyHelpers(
this.$notify as Parameters<typeof createNotifyHelpers>[0],
);
const settings = await this.$accountSettings();
this.activeDid = settings?.activeDid || "";
this.apiServer = settings?.apiServer || "";
@ -419,7 +421,7 @@ export default class OnboardMeetingView extends Vue {
} else {
this.newOrUpdatedMeetingInputs = this.blankMeeting();
}
} catch (error: any) {
} catch (error: unknown) {
this.newOrUpdatedMeetingInputs = this.blankMeeting();
}
}

Loading…
Cancel
Save