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
{{ message }}
Repository navigation
forceQuotes quotes non-string scalars and emits explicit type tags in v5 #798
In js-yaml 5.4.1, enabling forceQuotes applies the quoted style not only to JavaScript strings, but also to booleans, numbers, and null.
As a result, explicit tags such as !!bool, !!int, !!float, and !!null are emitted to preserve their types.
The documentation describes forceQuotes as quoting “all non-key strings,” and v4 only quoted string values. Is this behavior intentional, or is it a regression from v4?
The emitted YAML is valid, and dump() followed by load() preserves the original types. The issue is not the use of explicit tags itself, but that forceQuotes is being applied to non-string scalar values.
The v5.1.0 changelog also describes the restored option as forcing quotes around non-key strings.
However, applyForceQuotesOption() currently checks only whether the scalar is plain and is not a key. It does not check the scalar’s semantic tag before changing its style.
Once a non-string scalar is quoted, the presenter correctly emits its explicit tag to preserve its type:
Activity
Fix `forceQuotes` quoting non-string scalars, #798
puzrin commentedon Sep 13, 2026
Thank you!
puzrin commentedon Sep 13, 2026
Fixed in 5.4.2