Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: check relationships indexed access for undefined #2278

Merged
merged 1 commit into from Mar 13, 2023

Conversation

wkillerud
Copy link
Contributor

Description

After a change of relationTo in a relationship field, an existing global from before the change caused a crash in the admin UI. The whole page turned blank, and the console logged a TypeError pointing to relationMap[relation].push, where relationMap[relation] was undefined.

TypeScript does not flag undefined as a possibility in these scenarios unless both strict and noUncheckedIndexedAccess are turned on in the compiler options.

I tried to add undefined explicitly in the type definition for RelationMap, but it had no effect.

  • I have read and understand the CONTRIBUTING.md document in this repository

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

Checklist:

  • I have added tests that prove my fix is effective or that my feature works
  • Existing test suite passes locally with my changes
  • I have made corresponding changes to the documentation

@jmikrut jmikrut merged commit dbf976e into payloadcms:master Mar 13, 2023
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.

None yet

2 participants