TypeScript TS2349: This expression is not callable
TS2349 means the value has no call signature at that point. Narrow unions, fix module default imports and guard optional calls instead of asserting.

Introduction & Quick Summary
TypeScript refuses a call that JavaScript would happily attempt:
error TS2349: This expression is not callable.
Type 'string | (() => void)' has no call signatures.Quick answer: the value being called does not have a call signature in its declared type. Either it really is not a function at that point, or the type is too wide (a union, a namespace object, an optional member) and the compiler cannot prove it is a function without a narrowing check.
const handler: string | (() => void) = getHandler();
handler(); // TS2349
if (typeof handler === "function") handler(); // ok, narrowedThe message names a type, and that type is the clue: string, {} and Function | undefined each point at a different cause. This guide covers call signatures, why unions trigger the error, and fixes that keep the code type-safe.
Core Mechanics, Signatures & Reproducible Setup
A call signature is part of a type. (a: number) => string carries one; string carries none; an object type carries one only when it is written with a call signature or a method. typeof an imported module is an object of exports, not a function.
type Handler = (event: string) => void;
interface Callable {
(input: string): number; // call signature
description: string; // properties are allowed alongside it
}
const parse: Callable = Object.assign((s: string) => s.length, { description: "length" });
parse("abc"); // 3Reproduce the error in a strict project:
mkdir ts2349 && cd ts2349
npm init -y >/dev/null
npm i -D typescript@5
npx tsc --init --strict
cat > index.ts <<'EOF'
function resolve(value: string | (() => string)): string {
return value();
}
EOF
npx tsc --noEmit
# error TS2349: This expression is not callable.The compiler narrows a union by discriminant, typeof, in, instanceof and user-defined predicates. Assignment narrowing works only when the declared type of the target is narrow enough to keep the narrowed member.
| Declared type | Callable? | Why |
|---|---|---|
() => void | yes | single call signature |
(a: string) => void or undefined | no, without a guard | union member may be undefined |
{ run(): void } | yes, x.run() | method signature on the object |
{ run: () => void } | yes, x.run() | property holding a function type |
typeof import("./mod") | no | module object, call a named export |
Function | callable as any result | loses parameters and return type |
object | no | no members at all |
any | yes | no checking, no help |
Function is a trap: it compiles, returns any and checks nothing.
declare const f: Function;
f("anything", 123); // compiles, no argument checkingUse an explicit signature instead, and prefer narrowing over assertion.
| Technique | Example | Narrowed inside |
|---|---|---|
typeof guard | typeof v === "function" | yes |
| truthiness | if (v) v() | yes for undefined and null only |
in check | "call" in v | discriminated objects |
| assertion | v as () => void | unchecked, no runtime effect |
| predicate | function isFn(x: unknown): x is () => void | yes, reusable |
| generic constraint | <T extends (...a: any[]) => any> | at the boundary |
Key Comparison Table
| Symptom in the type | Likely cause | Correct fix |
|---|---|---|
Type 'string or number' has no call signatures | value holds data, not a function | call the function that produced it, or narrow |
Type 'X or undefined' has no call signatures | optional member or lookup miss | if (x) x() or x?.() |
Type 'typeof import("...")' has no call signatures | calling a module object | call mod.default or a named export |
Type '{}' has no call signatures | widened literal or generic default | annotate the parameter, constrain the generic |
Type 'Function' has no call signatures in strict mode | older lib definitions | replace Function with a real signature |
This expression is not callable on a class | calling the class instead of a method | new C() or obj.method() |
| Goal | Safe pattern | Risk of the shortcut |
|---|---|---|
| Call maybe-missing callback | callback?.(value) | callback!() throws at runtime |
| Call union member | typeof v === "function" guard | as any hides real mismatches |
| Type a JS utility | declare function util(x: string): void | require() returns any |
| Store functions in a map | Record<string, (e: Event) => void> | Record<string, Function> |
| Forward arguments | generic rest (...args: P) => R | typed any[] loses inference |
| Test for callability | typeof x === "function" | x instanceof Function crosses realms |
Practical Edge Cases, Error Fixes & Deep Dive Code Examples
1. A union of a function and data
type Input = string | (() => string);
function read(input: Input): string {
if (typeof input === "function") return input();
return input;
}The guard is required because the declared type keeps both members. A common variant is a callback that may be omitted:
function run(task: () => void | undefined) {
task(); // TS2349: undefined has no call signatures
}
function runFixed(task?: () => void) {
task?.(); // ok, optional call
}Optional parameters and optional properties behave the same way: the call must be guarded or use ?.().
2. Module objects, default exports and interop
import * as path from "node:path";
path(); // TS2349: module namespace is not callable
path.join("a", "b"); // call a member
import express from "express";
const app = express(); // ok only with esModuleInterop or allowSyntheticDefaultImportsWith "module": "nodenext", esModuleInterop is implied and require() of a CommonJS module yields a typed shape. In older configs, import * as express from "express"; express() fails with TS2349 exactly because a namespace object cannot be called. Use a default import, or import express = require("express") in CommonJS output.
3. Optional methods and class members
class Client {
send?: (body: string) => void;
close(): void {}
}
const c = new Client();
c.send("x"); // TS2349, possibly undefined
c.send?.("x"); // ok
c.close(); // ok, method signatureA class method is callable through an instance, never through the class itself unless it is static. Client.close() is TS2339 while Client.close on an instance is fine.
4. Objects that look callable but are not
const config = { onReady: undefined as undefined | (() => void) };
config.onReady(); // TS2349
if (config.onReady) config.onReady();JSON.parse output is any, so it hides the problem until a typed boundary is added:
interface Hooks { onReady?: () => void }
const hooks = JSON.parse(raw) as Hooks;
hooks.onReady?.();Validating with a schema is stronger than asserting, but the optional call is what removes the error either way.
5. Overloads, call signatures and generics
interface Parser {
(input: string): string[];
(input: string[]): string;
}
function apply<T extends (...args: any[]) => any>(fn: T): ReturnType<T> {
return fn();
}A generic constrained to a function type is callable inside the body; a generic constrained to object or left unconstrained is not. When a factory returns T and you need to call it, constrain T:
function callFactory<T extends () => unknown>(factory: T): ReturnType<T> {
return factory() as ReturnType<T>;
}6. Missing or wrong type packages
const yaml = require("js-yaml"); // any, no error, no safety
yaml.load("a: 1");Without @types/js-yaml, import yaml from "js-yaml" can resolve to a namespace whose members are untyped, and calls on the wrong member surface as TS2349. Install the types package, or write a minimal ambient declaration:
declare module "js-yaml" {
export function load(input: string): unknown;
}The error usually disappears once the declaration matches the real export style (named versus default). Use the JSON formatter to inspect a payload shape before writing the interface, and the diff checker to compare two compiler outputs after a config change.
Common Compilation/Runtime Mistakes & Version Gotchas
- Asserting instead of narrowing.
(value as () => void)()compiles and then throwsvalue is not a functionin production. The assertion is erased at runtime. - Assuming
strictis on. WithoutstrictNullChecks,undefinedis assignable everywhere and the same code compiles; the error appears only after enabling strict mode, so CI and local configs must match. - Widening through a mutable variable.
let fn = maybeFn;wheremaybeFnis(() => void) | undefinedkeeps the union. Reassignment inside a closure also defeats narrowing, because the value may change between guard and call. Functionas a parameter type. It is callable, returnsany, and accepts any argument list. Library authors still ship it, so wrap it:type AnyFn = (...args: unknown[]) => unknown.instanceof Function. It fails across iframes, workers andvmcontexts even for real functions.typeof x === "function"does not.- Calling
this-dependent methods detached.const { close } = client; close();compiles if the signature matches but throwsCannot read properties of undefined. Bind it or call it as a member. - Version note. Since TypeScript 4.9, unlisted property access on
unknownnarrows more strictly, and since 5.0 decorator typing changed; both can turn previously accepted calls into TS2349 when the value came from a decorator or asatisfiesexpression. - Declaration drift. Two copies of
@types/nodeor a monorepo with duplicate@types/reactproduce union types that no guard satisfies.npm ls @types/nodeand a single sharedtypesarray intsconfigresolve it.
The durable fix is a type that describes what is there: a specific signature, a discriminated union or an optional member.
Official documentation: TypeScript handbook: narrowing and function types.
Official references
primary documentationThe TypeScript documentation that defines the behaviour this guide explains.
Try matching browser tools
All toolsSmall utilities that fit TypeScript work — they run entirely in this browser tab, so nothing you paste leaves your device.
Related TypeScript guides
All TypeScript guidesTypeScript: Cannot find name 'process' with @types/node
TS2304 on process or Buffer means the compiler has no Node declarations. Install @types/node, stop excluding it, and align its version to the runtime.
TypeScript TS2532: Object is possibly 'undefined'
TS2532 means strict null checks cannot prove a value exists before reading through it. Guard it, add optional chaining, or narrow the type at the source.
TypeScript TS18046: 'e' is of type 'unknown'
TS18046 comes from useUnknownInCatchVariables: a caught error is unknown, not any. Narrow it with instanceof or a type guard before reading message.
TypeScript TS2339: Property does not exist on type
TS2339 means the declared type has no such member. Declare the shape, narrow unions and guard unknown values instead of casting at the read.
More in TypeScript
All TypeScript guidesThe guides filed next to this one in TypeScript, in library order.