Make kind property readonly in ReferenceListSource#41
Conversation
Co-authored-by: feuersteiner <18667704+feuersteiner@users.noreply.github.com>
kind property readonly in ReferenceListSource
0a9f8f0
into
39-major-refactor-to-orgnaize-and-split-into-packages
There was a problem hiding this comment.
Pull request overview
This PR enhances type safety by making the kind property readonly in the ReferenceListSource class, preventing accidental reassignment after construction. The change aligns with TypeScript best practices for immutable discriminator properties.
Changes:
- Added
readonlymodifier to thekindproperty inReferenceListSourceclass
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
|
||
| export class ReferenceListSource extends SourceBase { | ||
| kind = SourceKind.ReferenceList; | ||
| readonly kind = SourceKind.ReferenceList; |
There was a problem hiding this comment.
While adding readonly to the kind property is a good practice, this creates an inconsistency with the other source classes in the codebase. The DocumentSource (document.ts:4), ListSource (list.ts:16), and ReferenceDocumentSource (reference-document.ts:4) classes all declare kind without the readonly modifier. Consider applying this change to all source classes for consistency, or document why only ReferenceListSource requires this protection.
| readonly kind = SourceKind.ReferenceList; | |
| kind = SourceKind.ReferenceList; |
The
kindproperty onReferenceListSourcewas mutable, allowing accidental reassignment post-construction.Change
readonlymodifier tokindinReferenceListSource💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.