-
Notifications
You must be signed in to change notification settings - Fork 1.5k
[CL-761] Enable strict template typechecking #17334
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
base: main
Are you sure you want to change the base?
[CL-761] Enable strict template typechecking #17334
Conversation
|
Great job! No new security vulnerabilities introduced in this pull request |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #17334 +/- ##
=======================================
Coverage 41.25% 41.25%
=======================================
Files 3545 3545
Lines 102007 102019 +12
Branches 15302 15305 +3
=======================================
+ Hits 42080 42090 +10
- Misses 58162 58164 +2
Partials 1765 1765 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
…wser-strict-template-type-check
nick-livefront
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Only some 🎨 to utilize our CipherViewLikeUtils which will handle the logic between a full CipherView and CipherListView for you!
| protected archivedCiphers$ = this.userId$.pipe( | ||
| switchMap((userId) => this.cipherArchiveService.archivedCiphers$(userId)), | ||
| ); | ||
| ) as Observable<CipherView[]>; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
❓ Was this needed? archivedCiphers$ has a return type of Observable<CipherView[]>, I would expect that the type could be inferred.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@nick-livefront For some reason, yes. The return type wasn't being inferred correctly here. I thought the same thing. Here were the original type errors. Several related to the 'cipher' argument being passed into the handlers like this one. Very open to other possible fixes for this. This solution seemed like the least intrusive but, I don't love it either TBH
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, I had to restart my TypeScript and Eslint locally to see the same errors as in CI. archivedCiphers$ has a return type of Observable<CipherListView[]>. The handlers are only accepting of CipherListView, they'll need to be updated to accept CipherListView and you can then refactor to use the respective helper CipherListViewUtils method for the logic.
For the template related errors, you could assign CipherListViewUtils to the component so it can be used directly in the template:
/// class
protected CipherListViewUtils = CipherListViewUtils;
// template
@if (CipherViewLikeUtils.hasAttachments(cipher)) {
<i class="bwi bwi-paperclip bwi-sm" [appA11yTitle]="'attachments' | i18n"></i>
}There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cool. I'll look into that approach instead. Will hit you up if I run into anything weird. Thanks
| if ("hasAttachments" in cipher) { | ||
| return cipher.hasAttachments; | ||
| } | ||
| return cipher.attachments > 0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🎨 The CipherViewLikeUtils has a hasAttachments helper method that handles the logic between CipherListView and CipherView that can be utilized here.
hasAttachments(cipher: PopupCipherViewLike): boolean {
return CipherViewLikeUtils.hasAttachments(cipher);
}There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@nick-livefront I'm finishing up this ticket for Bryan since he's OOO this week -- are the current changes sufficient or are you suggesting to entirely replace the contents of these methods with the helpers from CipherViewLikeUtils?
| * Get the subtitle for a cipher. CipherView has a subTitle getter, | ||
| * while CipherListView has a subtitle property. | ||
| */ | ||
| getSubtitle(cipher: PopupCipherViewLike): string | undefined { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🎨 Parallel to the above, CipherViewLikeUtils has a getSubtitle helper method
| * Check if a cipher has a decryption failure. CipherView has this property, | ||
| * while CipherListView does not. | ||
| */ | ||
| hasDecryptionFailure(cipher: PopupCipherViewLike): boolean { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🎨 And one more helper in CipherViewLikeUtils, decryptionFailure
| // CipherListView doesn't have decryptionFailure, so we use optional chaining | ||
| if ("decryptionFailure" in cipher && cipher.decryptionFailure) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🎨 CipherViewLikeUtils.decryptionFailure can be utilized here as well.
coroiu
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not much to say from a platform perspective :)
| {{ "save" | i18n }} | ||
| </button> | ||
| <button bitButton type="button" buttonType="secondary" popupBackAction> | ||
| <button bitButton type="button" buttonType="secondary" [popupBackAction]="undefined"> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[popupBackAction]="undefined" seems very clunky. Can we just change the popupBackAction selector to not be [popupBackAction] and rather be popupBackAction which should let you use the original syntax.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Hinton Agreed, don't love this either. I'll give that a try!
d151c53
…wser-strict-template-type-check
|
Claude finished @BryanCunningham's task —— View job PR Review: Enable Strict Template Type CheckingThis PR successfully enables SummaryThe type fixes are generally correct but can be improved by consistently using the existing FindingsFinding 1: Inconsistent use of utility helpers between components (🎨)
However, hasAttachments(cipher: PopupCipherViewLike): boolean {
if ("hasAttachments" in cipher) {
return cipher.hasAttachments;
}
return cipher.attachments > 0;
}This duplicates logic already in Recommendation: Replace the three manual helper methods in
This addresses @nick-livefront's earlier review comments. Expose Finding 2: Type assertions could be more precise (💭) Multiple locations use
The Question: Is there a type mismatch between Finding 3: Addressing @vleague2's question from review comments (💭) @vleague2 asked whether to "entirely replace the contents of these methods with the helpers from Answer: Yes, that's exactly what should be done. The methods in Finding 4: Test coverage concerns ( Codecov shows 23.8% patch coverage with 16 lines missing coverage, primarily in:
The new helper methods added to Finding 5: PR title and description quality (💭) The PR title "CL-761 Enable strict template typechecking" is clear and specific. The objective section appropriately acknowledges uncertainty about correctness, which is good transparency. However, it would be helpful to add a brief test plan describing how the changes were verified (e.g., "Manually tested archive and trash views in browser extension to verify no runtime errors"). Additional ObservationsPositive aspects:
No major concerns found in:
Recommendations
|
coroiu
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No platform changes since last review 👍

🎟️ Tracking
https://bitwarden.atlassian.net/browse/CL-761
📔 Objective
Without a ton of context fixing the existing type errors was a bit of a guessing game. I had Claude help out here so please let me know which fixes are correct and which may have unintended side effects.
📸 Screenshots
⏰ Reminders before review
🦮 Reviewer guidelines
:+1:) or similar for great changes:memo:) or ℹ️ (:information_source:) for notes or general info:question:) for questions:thinking:) or 💭 (:thought_balloon:) for more open inquiry that's not quite a confirmed issue and could potentially benefit from discussion:art:) for suggestions / improvements:x:) or:warning:) for more significant problems or concerns needing attention:seedling:) or ♻️ (:recycle:) for future improvements or indications of technical debt:pick:) for minor or nitpick changes