Studio: Resolve type error for blueprint steps - #2694
Conversation
📊 Performance Test ResultsComparing a952fba vs trunk site-editor
site-startup
Results are median values from multiple test runs. Legend: 🟢 Improvement (faster) | 🔴 Regression (slower) | ⚪ No change (<50ms diff) |
epeicher
left a comment
There was a problem hiding this comment.
Thanks @katinthehatsite! I can confirm that I no longer see the type errors. LGTM! ![]()
| Before | After |
|---|---|
![]() |
![]() |
I think the package-lock.json changes are not required, and if you merge with latest trunk the E2E error will be fixed
| } | ||
| const existingSteps = blueprint.steps || []; | ||
| blueprint.steps = [ ...setupSteps, ...existingSteps ]; | ||
| const blueprintDecl = blueprint as BlueprintV1Declaration; |
There was a problem hiding this comment.
I don't see error in my Cursor, maybe something is broken in my local configuration, but in general the solution seems like a workaround for wp-playground and we need to report it.
What concerns me is:
- Above in the code we define
let blueprint: Blueprint | undefined; - Under the hood we have
export type Blueprint = BlueprintV1 | BlueprintV2; - Under the hood of the previous statement, we have
export type BlueprintV1 = BlueprintV1Declaration | BlueprintBundle; - So, ultimately it should be
BlueprintV1Declaration. Since you see that error and castingas BlueprintV1Declarationfixes the issue, then we indeed should report this ts bug instead of adding workaround.
It's ts, so it shouldn't affect anything, and I would go with keeping the error as is and reporting the bug. Unless it breaks something right now, but it seems it isn't.
But as a temporary solution, I think we can go with the approach in this PR.
WDYT? Am I missing something?
UPDATE: restarting the Cursor - showed the error to me.
There was a problem hiding this comment.
I think we can merge this for now and I will report this to Playground team. It is likely will be marked a low priority so it might take a while for the fix to come in.
There was a problem hiding this comment.
I added follow up here: WordPress/wordpress-playground#3336
There was a problem hiding this comment.
This isn't a safe type assertion. Typescript is flagging a legitimate type error here.
I recommend changing the type of the let blueprint declaration to BlueprintV1Declaration. This will require us to also change the return type of filterUnsupportedBlueprintFeatures, and potentially some other related functions. All of this is what we want, though, because BlueprintV1Declaration is the data format we support.
There was a problem hiding this comment.
I will take a look 👀
There was a problem hiding this comment.
I went down a rabbit hole with this and ended up publishing #2719, which addresses the problem and some related issues.
gcsecsey
left a comment
There was a problem hiding this comment.
Thanks @katinthehatsite for fixing this. This LGTM and I see no more issues on the create file. 👍
Also, when creating a new site, I see no errors:
There was a problem hiding this comment.
The changes are fixing the issue 👍 So feel free to move forward and merge it. I just shared my thoughts above.


Related issues
N/A
I noticed this issue while working on something else.
Proposed Changes
This PR resolves the type error in
studio/apps/cli/commands/site/create.ts:Testing Instructions
studio/apps/cli/commands/site/create.tsand confirm there are no type errorsPre-merge Checklist