Skip to content

Conversation

@kharus
Copy link
Contributor

@kharus kharus commented Mar 12, 2025

No description provided.

@kharus kharus requested a review from Copilot March 12, 2025 05:27
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR converts the Label implementation from subclassing (PreLabel and PrePostLabel) to a discriminated union, streamlining label creation and usage across the model and tests.

  • Replaces abstract Label and its subclasses with a union type for labels
  • Updates the deserialization and encoding functions to handle the new structure
  • Revises unit tests to use the discriminated union syntax

Reviewed Changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.

File Description
src/model/Item.ts Removed classes and created a union type for Label; updated label deserialization and encoding logic.
src/model/tests/Item.test.ts Modified tests to use the new Label union values.
src/model/tests/Interview.test.ts Updated label instantiation to use the union format in tests.
src/model/tests/Relevance.test.ts Replaced PreLabel usage with the union type for Label.
Comments suppressed due to low confidence (1)

src/model/Item.ts:98

  • Consider updating the error message to include the full JSON payload (e.g., using JSON.stringify(json)) to provide more context when deserialization fails.
throw new Error(`Unknown label type: ${json.type}`);

@kharus kharus merged commit 1498047 into main Mar 12, 2025
1 check passed
@kharus kharus deleted the Label-to-DiscriminatedUnion branch March 12, 2025 05:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants