Skip to content

Add non-null assertion to codeEventEntity for consistent fail-fast behavior#613

Closed
Copilot wants to merge 2 commits intofix-entity-creation-blockingfrom
copilot/sub-pr-602
Closed

Add non-null assertion to codeEventEntity for consistent fail-fast behavior#613
Copilot wants to merge 2 commits intofix-entity-creation-blockingfrom
copilot/sub-pr-602

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Nov 4, 2025

Addresses review feedback on #602 to add non-null assertion to codeEventEntity, ensuring it fails fast if the entity doesn't exist rather than silently accepting undefined.

Changes

  • Refactored codeEventEntity from conditional assignment in forEach loop to .find()! pattern matching pinActiveEntity
  • Added ESLint disable comments to both non-null assertions documenting intentional fail-fast behavior
  • Excluded CODE_EVENT_KEY from mainEntities array in forEach loop

Before:

let codeEventEntity: LockCodeManagerEntityEntry;
lockCodeManagerEntities.forEach((entity) => {
    // ...
    else if (entity.key === CODE_EVENT_KEY) {
        codeEventEntity = entity;  // May remain undefined
    }
    // ...
});

After:

// eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion
const codeEventEntity = lockCodeManagerEntities.find(
    (entity) => entity.slotNum === slotNum && entity.key === CODE_EVENT_KEY
)!;  // Explicit fail-fast if missing

Both pinActiveEntity and codeEventEntity now use identical patterns, asserting entities always exist per the Entity Creation Blocking Issue fix.


💡 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.

Co-authored-by: raman325 <7243222+raman325@users.noreply.github.com>
Copilot AI changed the title [WIP] Add non-null assertion to entity creation fix Add non-null assertion to codeEventEntity for consistent fail-fast behavior Nov 4, 2025
Copilot AI requested a review from raman325 November 4, 2025 11:12
@raman325
Copy link
Copy Markdown
Owner

raman325 commented Nov 5, 2025

Already incorporated into the parent branch

@raman325 raman325 closed this Nov 5, 2025
@raman325 raman325 deleted the copilot/sub-pr-602 branch November 5, 2025 03:47
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