TypeScript Compiler API

ts.isCallExpression()

Tests whether a node is a CallExpression, exposing expression and arguments after narrowing. It does not establish that the call is valid or which overload is selected; consult semantic diagnostics and getResolvedSignature for that. Baseline: TypeScript 5.8.3; run locally with Node.js, not as a ByteMind CodeRunner exercise.

Formal Syntax & Structure

typescript syntaxtypescript
ts.isCallExpression(node: ts.Node): node is ts.CallExpression

Parameters & Attributes

NameTypeDescription
nodets.NodeAST node to inspect.

Working Example

Example Snippettypescript
// Use a new empty directory. Install: npm install --save-exact typescript@5.8.3// File: example.cjs (omit this label)const ts = require("typescript");const assert = require("node:assert/strict");function parse(text) {  return ts.createSourceFile("input.ts", text, ts.ScriptTarget.ES2022, true, ts.ScriptKind.TS);}const f=parse("f(1); new F();"); const call=f.statements[0].expression;assert(ts.isCallExpression(call)); assert.equal(call.arguments.length,1); assert(!ts.isCallExpression(f.statements[1].expression));console.log("call expression; new expression excluded");
// Run: node example.cjs// Expected stdout: call expression; new expression excluded
TypeScript Reference