Skip to content

setScalarValue

setScalarValue(token, value, context?): void

Defined in: src/source/cst-scalar.ts:165

Set the value of token to the given string value, overwriting any previous contents and type that it may have.

Best efforts are made to retain any comments previously associated with the token, though all contents within a collection’s items will be overwritten.

Values that represent an actual string but may be parsed as a different type should use a type other than 'PLAIN', as this function does not support any schema operations and won’t check for such conflicts.

Token

Any token. If it does not include an indent value, the value will be stringified as if it were an implicit key.

string

The string representation of the value, which will have its content properly indented.

boolean

In most cases, values after a key should have an additional level of indentation.

boolean

Being within an implicit key may affect the resolved type of the token’s value.

boolean

Being within a flow collection may affect the resolved type of the token’s value.

ScalarType

The preferred type of the scalar token. If undefined, the previous type of the token will be used, defaulting to 'PLAIN'.

void