Refactor StudentType and Answer from interfaces to classes, rename to Student#361
Merged
fuhrmanator merged 9 commits intomainfrom Oct 14, 2025
Merged
Conversation
Co-authored-by: fuhrmanator <7606540+fuhrmanator@users.noreply.github.com>
Co-authored-by: fuhrmanator <7606540+fuhrmanator@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Refactor StudentType and Answer types from interfaces to classes
Refactor StudentType and Answer from interfaces to classes for improved type safety
Oct 9, 2025
fuhrmanator
requested changes
Oct 10, 2025
| } | ||
|
|
||
| export interface StudentType { | ||
| export class StudentType { |
Collaborator
There was a problem hiding this comment.
Since this is no longer an interface, the class should be called Student.
Contributor
Author
There was a problem hiding this comment.
Renamed StudentType class to Student throughout the codebase (commit: short hash will be added after push)
Collaborator
|
@copilot make the requested changes |
Co-authored-by: fuhrmanator <7606540+fuhrmanator@users.noreply.github.com>
Copilot
AI
changed the title
Refactor StudentType and Answer from interfaces to classes for improved type safety
Refactor StudentType and Answer from interfaces to classes, rename to Student
Oct 10, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Overview
This PR refactors
StudentTypeandAnswerfrom TypeScript interfaces to classes throughout the codebase, improving type safety, consistency, and maintainability. The refactoring makes theroomproperty mandatory, adds anisConnectedfield with proper default values, and renames the class fromStudentTypetoStudentto follow class naming conventions.Motivation
Previously,
StudentTypeandAnswerwere defined as interfaces with object literal instantiation, which had several drawbacks:roomproperty was optional, leading to potential null/undefined bugsanswersandisConnectedfieldsStudentType) was used instead of class naming conventionChanges
Type Definitions
Before:
After:
Usage Pattern
Before:
After:
Server-Side Updates
Updated
server/socket/socket.jsto include the new required fields when creating student objects:Files Modified
client/src/Types/StudentType.tsx- renamed class fromStudentTypetoStudentserver/socket/socket.jsas anyassertionsas anytype assertions removed from tests by properly wrapping values in arraysStudentTypetoStudentwhile keeping file name asStudentType.tsxTesting
Benefits
roomfield is now mandatory, preventing potential runtime errors from undefined room valuesanswersandisConnectedreduces boilerplateStudentfollows TypeScript/JavaScript class naming conventionsas anyassertions by properly typing array valuesBreaking Changes
While this is a refactoring that changes the internal structure, the API remains compatible as the class instances have the same properties as the previous interface objects. All usage sites have been updated in this PR. The class is now named
Studentinstead ofStudentTypeto follow proper class naming conventions.Original prompt
This pull request was created as a result of the following prompt from Copilot chat.
💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.