fix: resolve TS2345 in PerspectivePlugins customElements.define#1844
Merged
fix: resolve TS2345 in PerspectivePlugins customElements.define#1844
Conversation
…define` call Cast `PerspectiveDatagridJSONViewerPlugin` to `CustomElementConstructor` to satisfy TypeScript's stricter type checking under `moduleResolution: "bundler"`. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Contributor
WalkthroughSmall, localized edits: added a type cast when registering a custom element, simplified Select value/defaultValue mapping to remove redundant nullish-coalescing, and reordered some imports in two components. No runtime logic or control flow changes. Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes 🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
The `?? []` fallback was inside the `.map()` callback, applying to each mapped object literal (always truthy, so always a no-op). Moved it outside so it applies to the nullable array itself: `arr?.map(...) ?? []`. Fixes esbuild warnings: "The ?? operator here will always return the left operand" Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
mdesmet
approved these changes
Mar 24, 2026
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.
Summary
PerspectiveDatagridJSONViewerPluginat thecustomElements.define()call to fix TS2345 build error??operator precedence bug in 4 files where the nullish fallback was inside.map()(always no-op) instead of outside itContext
TS2345: Started after PR #1833 (
b0a58e4a) changedmoduleResolutionfrom"node"to"bundler"inwebview_panels/tsconfig.json. Under"bundler"resolution, TypeScript requirescustomElements.define()arguments to fully satisfyCustomElementConstructor. The plugin class extends its base dynamically viacustomElements.get(), which TS cannot statically verify — the cast is safe at runtime.??precedence:tags?.map((v) => ({ label: v, value: v }) ?? [])— the?? []applied to each mapped object literal (always truthy, never triggered). Fixed totags?.map((v) => ({ label: v, value: v })) ?? []so the fallback correctly applies when the source array is nullish. Same behavior when the array exists, correct fallback when it doesn't.Test plan
npx tsc --noEmitpasses with zero errors??operator warnings