You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The original code was written to return true if the option is undefined and the truthy value of the option otherwise. It was noted by @Gerrit0 that typeof will always return a string, therefore the typeof check will always return false and the expression should be simplified to value = !!value;.
Since there is likely a bug in this code, it should be thoroughly reviewed and corrected.
The text was updated successfully, but these errors were encountered:
I spent some time looking into this and have determined that either value === undefined ? true : !!value or !!value is acceptable.
In the first case, we add a special case for converting an undefined value to true. This is somewhat consistent with other parts of the code base like setFlag(flag) will set the flag to true for a signature setFlag(flag: Flag, value = true).
The current behavior ignores this special case, the existing argument readers correctly handle it with the current logic, and the special case introduces a footgun if a user has a JS config file that returns boolean value as undefined (which normally coerces to false) turning true.
With this in mind, I think it is best left as is, with no special case.
In PR #845, a question came up about the parsing of boolean declaration options.
typedoc/src/lib/utils/options/declaration.ts
Lines 80 to 82 in 7799a89
The original code was written to return true if the option is undefined and the truthy value of the option otherwise. It was noted by @Gerrit0 that typeof will always return a string, therefore the typeof check will always return false and the expression should be simplified to
value = !!value;
.Since there is likely a bug in this code, it should be thoroughly reviewed and corrected.
The text was updated successfully, but these errors were encountered: