Fix some unsafe type assertions#2719
Conversation
katinthehatsite
left a comment
There was a problem hiding this comment.
Thanks for the fix, I explored similar solutions but I think this one is slightly better. This approach uses structuredClone instead of spread and my approach used shallow spread + index-based assignment.
Do we also need to update the Blueprint type in studio/apps/studio/src/modules/add-site/lib/apply-blueprint-form-values.ts ?
We should. Good catch 👍 Came up when I merged trunk |
|
Looks like I still need to update this PR to fix the failing tests… |
📊 Performance Test ResultsComparing 373aaa6 vs trunk site-editor
site-startup
Results are median values from multiple test runs. Legend: 🟢 Improvement (faster) | 🔴 Regression (slower) | ⚪ No change (<50ms diff) |
|
I've fixed the tests. The problem was caused by importing the In short… A bit of a mess for such a small issue. I decided to just copy and inline the I'd appreciate another review, @katinthehatsite 🙏 |
|
Please ignore the lint failures. They will be fixed when #2720 is merged into this branch. |
epeicher
left a comment
There was a problem hiding this comment.
Thanks for improving this @fredrikekelund! I have reviewed it, and I have just left a question for consideration. I have tested site creation using blueprints, and I have not found any issues. LGTM!
| * Prepares data for Sentry by stringifying nested objects to avoid normalization limits. | ||
| */ | ||
| export function sanitizeRunCLIArgs( args: RunCLIArgs ): Record< string, unknown > { | ||
| const blueprint = args.blueprint && 'steps' in args.blueprint ? args.blueprint : undefined; |
There was a problem hiding this comment.
This would return undefined for a blueprint that has no steps, but there are blueprints that can contain no steps, is this intentional?
There was a problem hiding this comment.
That's an excellent point! I was trying to appease TS here, but from a functionality perspective, you're right that this is lossy. I've updated the code and opted to use a type assertion after all.
|
Thanks for the review, @epeicher 🙏 |

Related issues
How AI was used in this PR
#2694 (comment) prompted me to look into ESLint rules to avoid similar problems. I found @typescript-eslint/no-unsafe-type-assertion and tried enabling it, letting Codex fix the errors. It did a decent job, but ultimately, there were too many errors for a single PR. The stuff that made it into this PR was mostly written by hand, except for
format-rtk-error.tsx.Proposed Changes
See the previous section for some background… In short, I tried enabling @typescript-eslint/no-unsafe-type-assertion but found too many errors. This PR primarily fixes up some type assertions related to blueprints, but also in
format-rtk-error.tsx,snapshot-slice.ts, andtools/common/lib/locale.ts.Testing Instructions
Pre-merge Checklist