[Bug]: Documentation & TypeScript Types inaccuracte for set systemPreferences.appLevelAppearance
#30413
Closed
3 tasks done
Labels
bug 🪲
component/typescript
documentation 📓
stale
status/confirmed
A maintainer reproduced the bug or agreed with the feature
Preflight Checklist
Electron Version
13.1.8
What operating system are you using?
macOS
Operating System Version
macOS Big Sur 11.4
What arch are you using?
arm64 (including Apple Silicon)
Last Known Working Electron version
No response
Expected Behavior
After attempting to reset the appLevelAppearance from either
light
ordark
to using the operating system appearance does not work by setting it tounknown
. That gave me a "conversion error".Taking a look into the source code for the
systemPreferences
API, one can see that there are in fact three possible ways of setting theappLevelAppearance
– light, dark and one being undocumented – namely thenull
value:electron/shell/browser/api/electron_api_system_preferences_mac.mm
Lines 44 to 47 in 4703dc0
In fact, the
appLevelAppearance
can successfully be reset by using the following line of code:I tested this and it worked out of the box.
Actual Behavior
However, upon trying this and set the appLevelAppearance to
null
, it turned out the Electron types (used for TypeScript) give me an error. But they do not give me an error using the wrong value of'unknown'
which throws the above-mentioned "conversion error".I recommend the following updates:
appLevelAppearance
setter acceptsnull
as a valid property to set the app-level appearance tonil
appLevelAppearance
at runtime by setting it tonull
Further, I think it might be more appropriate to consolidate getter and setter and, instead of returning "unknown" return the JavaScript representation of
nil
, namely:null
(or evenundefined
). Alternatively, the setter might acceptunknown
and convert that internally tonil
.Testcase Gist URL
No response
Additional Information
No response
The text was updated successfully, but these errors were encountered: