fix(ui): HasSsrOrSsg defaults to SSR branch for non-SSR apps#18356
Open
maiolica wants to merge 1 commit into
Open
fix(ui): HasSsrOrSsg defaults to SSR branch for non-SSR apps#18356maiolica wants to merge 1 commit into
HasSsrOrSsg defaults to SSR branch for non-SSR apps#18356maiolica wants to merge 1 commit into
Conversation
Build ResultsJSON API📜 No changes detected. Types📜 Changes detected: diff --git a/./current-build/types/feature-flag.d.ts b/./pr-build/types/feature-flag.d.ts
index 284c0dd..8de7cd7 100644
--- a/./current-build/types/feature-flag.d.ts
+++ b/./pr-build/types/feature-flag.d.ts
@@ -51,11 +51,11 @@ export type HasStore<T, U = {}> = IsFeatureEnabled<"store", T, U>;
export type HasSsr<T, U = {}> = IsFeatureEnabled<"ssr", T, U>;
export type HasSsg<T, U = {}> = IsFeatureEnabled<"ssg", T, U>;
-export type HasSsrOrSsg<T, U = {}> = true extends QuasarFeatureFlags[
- | "ssr"
- | "ssg"]
+export type HasSsrOrSsg<T, U = {}> = QuasarFeatureFlags["ssr"] extends true
? T
- : U;
+ : QuasarFeatureFlags["ssg"] extends true
+ ? T
+ : U;
export type HasPwa<T, U = {}> = IsFeatureEnabled<"pwa", T, U>;
export type HasCapacitor<T, U = {}> = IsFeatureEnabled<"capacitor", T, U>; |
HasSsrOrSsg defaults to SSR branch for non-SSR apps
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.
What kind of change does this PR introduce?
Does this PR introduce a breaking change?
The PR fulfills these requirements:
devbranch (orv[X]branch)Other information:
Problem
In a non-SSR/SSG app (SPA, PWA, Electron, Capacitor, Cordova, BEX), the programmatic language / icon-set setters no longer type-check when called with a single argument:
This worked through 2.21.1 and regressed in 2.21.2 (commit adc5d54, "feat(ui): prepare types for upcoming SSG mode", which switched the lang/iconSet singleton
setfromHasSsr<...>toHasSsrOrSsg<...>). Still present ondev.Root cause
Quasar.lang/Quasar.iconSetare the*Singletoninterfaces whosesetoverload is chosen byHasSsrOrSsg(ui/types/globals.d.ts):HasSsrOrSsgwas defined with the opposite direction of every other feature-flag helper:QuasarFeatureFlagshas[index: string]: boolean, and the app CLIs augment it with only the enabled flags (e.g.store: true) - they never declaressr: false. So in a non-SSR appQuasarFeatureFlags["ssr" | "ssg"]falls back to the index signatureboolean, andtrue extends booleanistrue, selecting the 2-argument SSR overload for everyone.Fix
Check each flag against
true(matchingIsFeatureEnabled), so an absent flag defaults toU(off).QuasarFeatureFlagsstays referenced; only the direction of the check changes. Equivalent one-liner:HasSsr<T, HasSsg<T, U>>.Verification
Resolved a TS program across all flag combinations:
T(2-arg)U(1-arg)ssr: trueTTssg: trueTTssr+ssgTTTypes-only, no runtime change; SSR/SSG apps keep the 2-arg overload.
HasSsrOrSsgis used only by the lang and iconSet singletonsetmethods.