Names
FUNCTION
@skmtc/lang-typescript 0.19.1createVariable
Creates a variable identifier - a value entity that declares with const and imports as a plain named import.
Signature
import { createVariable } from '@skmtc/lang-typescript'
createVariable(name: string, args?: CreateVariableArgs): TsIdentifierParameters
name, string required
args, CreateVariableArgs
typeName, string
Optional type annotation for typed variables.
exported, boolean
Whether the identifier is exported. Defaults to true.
Untyped variable
const count = createVariable('count');
console.log(count.name); // 'count'
console.log(count.type); // 'variable'Typed variable
const userId = createVariable('userId', { typeName: 'string' });
// TsDefinition renders: export const userId: string = …;