Merge branch 'master' into fix-deep-link

This commit is contained in:
2025-08-19 19:53:38 -06:00
24 changed files with 2293 additions and 495 deletions

View File

@@ -1,5 +1,5 @@
---
globs: **/src/**/*,**/scripts/**/*,**/electron/**/*
description: when dealing with types and Typesript
alwaysApply: false
---
```json
@@ -15,8 +15,8 @@ alwaysApply: false
# TypeScript Type Safety Guidelines
**Author**: Matthew Raymer
**Date**: 2025-08-16
**Status**: 🎯 **ACTIVE**
**Date**: 2025-08-19
**Status**: 🎯 **ACTIVE** - Type safety enforcement
## Overview
@@ -28,7 +28,8 @@ Practical rules to keep TypeScript strict and predictable. Minimize exceptions.
- Use explicit types. If unknown, use `unknown` and **narrow** via guards.
2. **Error handling uses guards**
- Reuse guards from `src/interfaces/**` (e.g., `isDatabaseError`, `isApiError`).
- Reuse guards from `src/interfaces/**` (e.g., `isDatabaseError`,
`isApiError`).
- Catch with `unknown`; never cast to `any`.
3. **Dynamic property access is typesafe**
@@ -43,6 +44,7 @@ Practical rules to keep TypeScript strict and predictable. Minimize exceptions.
## Type Safety Enforcement
### Core Type Safety Rules
<<<<<<< HEAD
- **No `any` Types**: Use explicit types or `unknown` with proper type guards
- **Error Handling Uses Guards**: Implement and reuse type guards from `src/interfaces/**`
- **Dynamic Property Access**: Use `keyof` + `in` checks for type-safe property access
@@ -56,13 +58,38 @@ Practical rules to keep TypeScript strict and predictable. Minimize exceptions.
- **Avoid Type Assertions**: Replace `as any` with proper type guards and interfaces
- **Narrow Types Properly**: Use type guards to narrow `unknown` types safely
- **Document Type Decisions**: Explain complex type structures and their purpose
=======
- **No `any` Types**: Use explicit types or `unknown` with proper type guards
- **Error Handling Uses Guards**: Implement and reuse type guards from
`src/interfaces/**`
- **Dynamic Property Access**: Use `keyof` + `in` checks for type-safe
property access
### Type Guard Patterns
- **API Errors**: Use `isApiError(error)` guards for API error handling
- **Database Errors**: Use `isDatabaseError(error)` guards for database
operations
- **Axios Errors**: Implement `isAxiosError(error)` guards for HTTP error
handling
### Implementation Guidelines
- **Avoid Type Assertions**: Replace `as any` with proper type guards and
interfaces
- **Narrow Types Properly**: Use type guards to narrow `unknown` types
safely
- **Document Type Decisions**: Explain complex type structures and their
purpose
>>>>>>> master
## Minimal Special Cases (document in PR when used)
- **Vue refs / instances**: Use `ComponentPublicInstance` or specific component
types for dynamic refs.
- **3rdparty libs without types**: Narrow immediately to a **known interface**;
do not leave `any` hanging.
- **Vue refs / instances**: Use `ComponentPublicInstance` or specific
component types for dynamic refs.
- **3rdparty libs without types**: Narrow immediately to a **known
interface**; do not leave `any` hanging.
## Patterns (short)
@@ -123,3 +150,15 @@ const keys = Object.keys(newSettings).filter(
- TS Handbook — https://www.typescriptlang.org/docs/
- TSESLint — https://typescript-eslint.io/rules/
- Vue 3 + TS — https://vuejs.org/guide/typescript/
---
**Status**: Active type safety guidelines
**Priority**: High
**Estimated Effort**: Ongoing reference
**Dependencies**: TypeScript, ESLint, Vue 3
**Stakeholders**: Development team
- TS Handbook — https://www.typescriptlang.org/docs/
- TSESLint — https://typescript-eslint.io/rules/
- Vue 3 + TS — https://vuejs.org/guide/typescript/