Skip to content

[F] formatIdentifier

function formatIdentifier(sv): string

Print a string as a TypeSpec identifier. If the string is a valid identifier, return it as is otherwise wrap it into backticks.

Parameters

ParameterTypeDescription
svstringIdentifier string value.

Returns

string

Identifier string as it would be represented in a TypeSpec file.

Example

printIdentifier("foo") // foo
printIdentifier("foo bar") // `foo bar`