Writing code

FUNCTION

withDescription

@skmtc/lang-typescript 0.19.1

Prepends a value with a multi-line JSDoc comment when a description is provided; returns the value unchanged otherwise. Each line of the description becomes a * gutter line, so an already-wrapped description renders as multiple comment lines.

Signature

import { withDescription } from '@skmtc/lang-typescript'

withDescription(value: Stringable, args: Modifiers): string

Parameters

value, Stringable required
args, Modifiers required
required, boolean

Whether the field is required (affects optional markers in generated types)

description, string

Human-readable description of the field (used in documentation)

nullable, boolean

Whether the field can be null (affects null union types)

Example
withDescription('export const API_URL = "...";', { description: 'Base URL' })
// /**
//  * Base URL
//  *\/
// export const API_URL = "...";

Returns

string