-
Notifications
You must be signed in to change notification settings - Fork 235
chore: fix storybook dev mode warning #5896
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
Conversation
|
📚 Branch Preview Links🔍 First Generation Visual Regression Test ResultsWhen a visual regression test fails (or has previously failed while working on this branch), its results can be found in the following URLs:
Deployed to Azure Blob Storage: If the changes are expected, update the |
nikkimk
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.
lgtm
marissahuysentruyt
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.
| if (!this.value || nextItem !== this.selectedItem) { | ||
| // updates picker text but does not fire change event until action is completed | ||
| if (!!nextItem) this.setValueFromItem(nextItem as MenuItem); | ||
| if (nextItem) this.setValueFromItem(nextItem as MenuItem); |
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.
I always get tripped up with !!- can you explain this change for me?
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.
@marissahuysentruyt They're functionally the same in this context. The !! pattern is useful when you need to store or return an explicit boolean, here its not the case. In this case, if (nextItem) already performs implicit boolean coercion, so the double negation adds no value. No impact on logic, just cleaner code.
Let me make it more clearer for you.
When !! matters:
// Storing as boolean (useful)
const hasNextItem: boolean = !!nextItem;
// Returning explicit boolean from function (useful)
function hasItem(): boolean {
return !!nextItem; // ensures boolean, not MenuItem | undefined
}
// API response where type matters (useful)
const response = { isActive: !!someValue };When !! is redundant:
// Conditional check (unnecessary - if already evaluates truthiness)
if (!!nextItem) { ... } // same as if (nextItem)
if (nextItem) { ... } // already truthy check
// Boolean operators (unnecessary)
const result = !!condition && doSomething(); // same as condition && doSomething()
Description
Define a safe
window.__swcshim in Storybook (storybook/preview.js) so debug warnings (window.__swc.warn) cannot crash the Storybook runtime.Motivation and context
storybook:buildfor 1st‑gen and serving the static Storybook docs, opening components that use overlays andSlottableRequestEventwould throwTypeError: Cannot read properties of undefined (reading 'warn').window.__swc?.DEBUGto true, causingwindow.__swc.warn(...)to be called even whenwindow.__swcis not defined in the Storybook runtime.console.warn) without breaking stories, and allows us to keep the experimental warning inSlottableRequestEvent.Related issue(s)
Screenshots (if appropriate)
Author's checklist
Reviewer's checklist
patch,minor, ormajorfeaturesManual review test cases
Device review