How to use the createIdentifier function from typescript

Find comprehensive JavaScript typescript.createIdentifier code examples handpicked from public code repositorys.

334
335
336
337
338
339
340
341
342
343
/** @param {import("typescript").Statement[]} statements */
function wrapInDeclareGlobal(statements) {
    return ts.createModuleDeclaration(
        undefined,
        [ts.createModifier(ts.SyntaxKind.DeclareKeyword)],
        ts.createIdentifier('global'),
        ts.createModuleBlock(statements),
        ts.NodeFlags.GlobalAugmentation
    );
}
fork icon116
star icon294
watch icon29

134
135
136
137
138
139
140
141
142
143
    const urlLiteral = ts.createLiteral(url);
    if (moduleKind < ts.ModuleKind.ES2015) {
        return ts.createPropertyAccess(ts.createCall(ts.createIdentifier('require'), [], [urlLiteral]), 'default');
    }
    else {
        const importName = ts.createIdentifier(`__NG_CLI_RESOURCE__${resourceImportDeclarations.length}`);
        resourceImportDeclarations.push(ts.createImportDeclaration(undefined, undefined, ts.createImportClause(importName, undefined), urlLiteral));
        return importName;
    }
}
fork icon0
star icon0
watch icon1

321
322
323
324
325
326
327
328
329
    const newStatement = [];
    newStatement.push(ts.createVariableStatement(isDefault ? undefined : modifiers, ts.createVariableDeclarationList([
        ts.createVariableDeclaration(name, undefined, pureIife),
    ], ts.NodeFlags.Let)));
    if (isDefault) {
        newStatement.push(ts.createExportAssignment(undefined, undefined, false, ts.createIdentifier(name)));
    }
    return newStatement;
}
fork icon0
star icon0
watch icon1

Other functions in typescript

Sorted by popularity

function icon

typescript.SyntaxKind is the most popular function in typescript (82777 examples)