How to use the createNodeArray function from typescript

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

362
363
364
365
366
367
368
369
370
const nonAugmentations = node.statements.filter((s) => !isGlobalAugmentation(s));

// If there is no top level await, don't move all the statements around
const hasTLA = node.statements.some(s => ts.isExpressionStatement(s) && s.expression.kind === ts.SyntaxKind.AwaitExpression);
// Move all statements to the top of the file that cannot appear in a function body
let hoistedStatements = hasTLA ? ts.createNodeArray(nonAugmentations.filter((s) => mustBeHoisted(s, isGlobal))) : ts.createNodeArray(nonAugmentations);

// The rest gets wrapped
const wrappedStatements = hasTLA ? nonAugmentations.filter(s => !mustBeHoisted(s, isGlobal)) : [];
fork icon116
star icon294
watch icon29

59
60
61
62
63
64
65
66
67
68
    ? visitComponentMetadata(node, styleReplacements, directTemplateLoading, resourceImportDeclarations, moduleKind)
    : node);
// replace properties with updated properties
if (styleReplacements.length > 0) {
    const styleProperty = ts.createPropertyAssignment(ts.createIdentifier('styles'), ts.createArrayLiteral(styleReplacements));
    properties = ts.createNodeArray([...properties, styleProperty]);
}
return ts.updateDecorator(node, ts.updateCall(decoratorFactory, decoratorFactory.expression, decoratorFactory.typeArguments, [
    ts.updateObjectLiteral(objectExpression, properties),
]));
fork icon0
star icon0
watch icon1

183
184
185
186
187
188
189
190
191
192
exports.isAngularLifecycleMethod = function (value) {
    return exports.ANGULAR_LIFECYCLE_METHODS.has(value);
};
exports.getDeclaredInterfaces = function (node) {
    var heritageClause = typescript_1.createNodeArray(node.heritageClauses).find(function (h) { return h.token === typescript_1.SyntaxKind.ImplementsKeyword; });
    return heritageClause ? heritageClause.types : typescript_1.createNodeArray([]);
};
exports.getDeclaredInterfaceNames = function (node) { return exports.getDeclaredInterfaces(node).map(exports.getSymbolName); };
exports.getDeclaredInterfaceName = function (node, value) {
    return exports.getDeclaredInterfaceNames(node).find(function (interfaceName) { return interfaceName === value; });
fork icon0
star icon0
watch icon1

+ 3 other calls in file

49
50
51
52
53
54
55
56
57
58
var callbackHandler = function (walkContext, node) {
    if (isDeclarationLike(node))
        validateDeclaration(walkContext, node);
};
var getClassDecoratorName = function (klass) {
    return typescript_1.createNodeArray(klass.decorators)
        .map(utils_2.getDecoratorName)
        .filter(isNotNullOrUndefined_1.isNotNullOrUndefined)
        .find(utils_2.isAngularClassDecorator);
};
fork icon0
star icon0
watch icon1

189
190
191
192
193
194
195
196
197
198
    if (utils_2.isSameLine(walkContext.sourceFile, firstDecoratorStartPos, declarationStartPos))
        return;
    walkContext.addFailureAt(firstDecoratorStartPos, declaration.getWidth(), Rule.FAILURE_STRING);
};
var validateDeclaration = function (walkContext, declaration, optionKey) {
    validateDecorators(walkContext, typescript_1.createNodeArray(declaration.decorators), declaration, optionKey);
};
var validateGetAccessorDeclaration = function (walkContext, node) {
    validateDeclaration(walkContext, node, OPTION_GETTERS);
};
fork icon0
star icon0
watch icon1

129
130
131
132
133
134
135
136
137
138
            updatedStatements[uIndex] = result;
        }
    }
    // if changes, return updated statements
    // otherwise, return original array instance
    return updatedStatements ? ts.createNodeArray(updatedStatements) : statements;
}
// TS 2.3 enums have statements that are inside a IIFE.
function findEnumIife(name, statement) {
    if (!ts.isExpressionStatement(statement)) {
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)