Comment Guide for AI Development with React and TypeScript

This is a comprehensive guide for AI tools to understand and generate proper comments in React and TypeScript projects. The guide includes operator terminology, documentation patterns, and best practices for code commenting.


# I'm using Windows operating system and Powershell

#Please do NOT be lazy, if you suggest a fix of a file, rewrite the codes without truncation, do not use something like [existing]  [... Continue with more sections and images ...] or [... Continue with existing codes ...], etc.

# React & TypeScript Code Documentation Guide

Use these specific terms when commenting code to make documentation searchable and consistent.

## Operators & Expressions

### Conditional Operators

- `? :` - **Ternary Conditional Operator**
- `&&` - **Logical AND Operator** (short-circuit evaluation)
- `||` - **Logical OR Operator** (short-circuit evaluation)
- `??` - **Nullish Coalescing Operator**

### Optional Chaining

- `?.` - **Optional Chaining Operator**
- `!.` - **Non-null Assertion Operator**

### Type Operations

- `as` - **Type Assertion Operator**
- `instanceof` - **Instance Check Operator**
- `typeof` - **Type Check Operator**
- `keyof` - **Index Type Query Operator**

### String Operations

- `+` - **String Concatenation Operator**
- `` ` `` - **Template Literal**
- `${expression}` - **String Interpolation**

### Array Operations

- `...` - **Spread Operator**
- `.map()` - **Array Mapping Method**
- `.filter()` - **Array Filter Method**
- `.reduce()` - **Array Reduction Method**
- `.find()` - **Array Find Method**

### Object Operations

- `...` - **Object Spread Operator**
- `?.` - **Optional Property Access**
- `??=` - **Nullish Coalescing Assignment**

### React-Specific

- `<>` - **Fragment Shorthand**
- `React.Fragment` - **Fragment Component**
- `useState` - **State Hook**
- `useEffect` - **Effect Hook**
- `useMemo` - **Memoization Hook**
- `useCallback` - **Callback Memoization Hook**

### TypeScript-Specific

- `interface` - **Interface Declaration**
- `type` - **Type Alias**
- `extends` - **Type Extension**
- `implements` - **Interface Implementation**
- `&` - **Intersection Type Operator**
- `|` - **Union Type Operator**

## Example Usage in Comments

```typescript
// Using Nullish Coalescing Operator (??) for default value
const value = data ?? defaultValue;

// Using Optional Chaining Operator (?.) for safe property access
const userName = user?.profile?.name;

// Using Ternary Conditional Operator (? :) for conditional rendering
const element = isLoading ? <Loading /> : <Content />;

// Using Logical AND Operator (&&) for conditional rendering
{
  isVisible && <Component />;
}

// Using Template Literal (``) with String Interpolation (${})
const greeting = `Hello, ${userName}!`;

// Using Array Spread Operator (...) for array copying
const newArray = [...existingArray];

// Using Type Assertion Operator (as) for type casting
const element = event.target as HTMLInputElement;

// Using Union Type Operator (|) for multiple types
type Status = "loading" | "success" | "error";


## Style Guide for Comments

1. Be specific with operator names
2. Include both the symbol and the full operator name
3. Mention the purpose after the operator specification
4. Keep comments concise but descriptive

Example:

```typescript
// Ternary Operator (? :) - Conditionally assigns role based on admin status
const role = isAdmin ? "administrator" : "user";