fix(browser-extension): guard project name against null textContent - #1636
Open
Agnik47 wants to merge 1 commit into
Open
fix(browser-extension): guard project name against null textContent#1636Agnik47 wants to merge 1 commit into
Agnik47 wants to merge 1 commit into
Conversation
`createProjectSelectionModal` declares its `onImport` callback with a
non-nullable `name`, but the call site passed `Node.textContent`, which the
DOM lib types as `string | null` under `Node`:
utils/ui-components.ts(611,13): error TS2345:
Argument of type '{ id: string; name: string | null; containerTag: string; }'
is not assignable to parameter of type '{ id: string; name: string; containerTag: string; }'.
Fall back to an empty string, matching the `containerTag` line directly below
it and every other `.textContent` read in the extension.
Runtime behaviour is unchanged: the options are built with
`option.textContent = project.name`, so the value is always a string, and the
disabled placeholder carries `value = ""` so the `if (selectedOption.value)`
guard already excludes it.
Also add a change-gated browser-extension `check-types` step to CI. The package
was never type-checked there, which is why this survived on main; the step
follows the existing SDK/playground detection pattern so it only runs when
apps/browser-extension changes.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017QSriDRoFLVze1BZGrAJHV
|
Note Production impact unlikely. No production resources are plausibly affected by this change. Polylane analysed |
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.
Fixes #1561
Problem
createProjectSelectionModaldeclares itsonImportcallback with a non-nullablename(utils/ui-components.ts:405-411), but the call site passesNode.textContent, typedstring | null:Fix
Fall back to an empty string. This matches the
containerTagline directly below it and every other.textContentread in the extension — this was the only unguarded site.selectedOption.textwas considered instead (it is typed non-nullable), but rejected: per spec it strips and collapses whitespace, which would silently alter project names.Runtime behaviour is unchanged. Options are built with
option.textContent = project.name(ui-components.ts:516-518), so the value is always a string, and the disabled placeholder carriesvalue = "", so the existingif (selectedOption.value)guard already excludes it. This is a type-safety fix only.One correction to the issue report
The issue states the lockfile pins TypeScript 5.8.3 as a single entry that this workspace dedupes onto. That is not what the current lockfile resolves:
bun install --frozen-lockfilegivesapps/browser-extensionits own nestedtypescript@5.9.3(the root copy is 5.8.3, but the extension does not use it).TS 5.9's DOM lib types
textContentas non-nullable onElement, socheck-typescurrently passes onmainas CI would install it — the error only appears under 5.8.x, which the package's own^5.8.3range still permits.So this is a latent defect rather than a red build today. Verified both ways:
mainTS2345, the package's only errorPreventing recurrence
apps/browser-extensionis not type-checked in CI, which is why this sat onmain. This PR adds a change-gatedcheck-typesstep following the existing SDK/playground detection pattern, so it runs only whenapps/browser-extensionchanges.Happy to drop the CI half if you'd rather keep this PR to the one-line fix.
Verification
bun run --cwd apps/browser-extension check-typesexits 0 under both TypeScript versions above; theTS2345was the only error reported under 5.8.3bun testinapps/browser-extension: 12 pass, 0 failbiome checkon the changed line is clean (the file reports a pre-existing CRLF diff on a Windows checkout only, identical before and after this change; the repo stores LF)🤖 Generated with Claude Code
https://claude.ai/code/session_017QSriDRoFLVze1BZGrAJHV