Improve Type Definitions for Major and Basket Data Structures
Current Issues
-
Redundant Track Information
Track is defined separately from where it's used
- Tracks are duplicated in both
Major.availableTracks and global availableTracks
-
Inconsistent Basket Definitions
- Some basket names have duplicates ("Ethics And Social Responsibility")
- Basket codes have overlaps (COR-OBHR appears twice)
- No clear relationship between
BasketType and BasketCode
-
Type Safety Gaps
- No validation that
Major.baskets references valid BasketTypes
- Track-specific baskets could be more strongly typed
Proposed Changes
- Consolidate Track Management
export const trackConfig = {
PD: { name: "Product Development", baskets: [...] },
DCS: { name: "Digital Cloud Solutions", baskets: [...] },
// ... other tracks with their specific configs
} as const;
export type Track = keyof typeof trackConfig;
- Improve Basket Type Safety
export type BasketDefinition = {
name: string;
code: BasketCode;
type: "core" | "track-specific" | "elective";
validTracks?: Track[];
};
export const basketDefinitions: Record<BasketType, BasketDefinition> = {
"Numeracy": {
name: "Numeracy",
code: "CORE",
type: "core"
},
// ... other baskets
};
- Stronger Major Type
export type Major = {
majorCode: MajorCode;
coreBasketsRequired: BasketType[];
trackRequirements: Record<Track, {
requiredBaskets: BasketType[];
electiveBaskets: BasketType[];
minimumCredits: number;
}>;
};
Benefits
- Single source of truth for track configurations
- Prevents duplicate/inconsistent basket definitions
- Better type safety for track-specific requirements
- Clearer relationship between baskets and their codes
- Easier to maintain and extend
Implementation Notes
- Will require refactoring existing code that uses these types
- Should add validation utils to ensure data consistency
- Consider adding TypeScript branded types for additional type safety
Improve Type Definitions for Major and Basket Data Structures
Current Issues
Redundant Track Information
Trackis defined separately from where it's usedMajor.availableTracksand globalavailableTracksInconsistent Basket Definitions
BasketTypeandBasketCodeType Safety Gaps
Major.basketsreferences validBasketTypesProposed Changes
Benefits
Implementation Notes