How to use the updateVariableDeclaration function from typescript

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

43
44
45
46
47
48
49
50
51
52
if (ts.isVariableStatement(node) && isDownleveledClass(node)) {
    const varDecl = node.declarationList.declarations[0];
    const varInitializer = varDecl.initializer;
    // Update node with the pure comment before the variable declaration initializer.
    const newNode = ts.updateVariableStatement(node, node.modifiers, ts.updateVariableDeclarationList(node.declarationList, [
        ts.updateVariableDeclaration(varDecl, varDecl.name, varDecl.type, ast_utils_1.addPureComment(varInitializer)),
    ]));
    // Replace node with modified one.
    return ts.visitEachChild(newNode, visitor, context);
}
fork icon0
star icon0
watch icon1

197
198
199
200
201
202
203
204
205
206
}
function updateHostNode(hostNode, expression) {
    // Update existing host node with the pure comment before the variable declaration initializer.
    const variableDeclaration = hostNode.declarationList.declarations[0];
    const outerVarStmt = ts.updateVariableStatement(hostNode, hostNode.modifiers, ts.updateVariableDeclarationList(hostNode.declarationList, [
        ts.updateVariableDeclaration(variableDeclaration, variableDeclaration.name, variableDeclaration.type, expression),
    ]));
    return outerVarStmt;
}
/**
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)