TypeScript Call Signatures Last Updated : 22 Jan, 2025 Comments Improve Suggest changes Like Article Like Report TypeScript call signatures define the parameter types and return types for function-like objects, enabling the creation of callable entities with additional properties.Allow objects to be invoked as functions while possessing properties.Enhance code flexibility by combining callable behavior with structured data.Syntax:type MyCallableObject = { (parameter1: Type1, parameter2: Type2): ReturnType; // Call signature propertyName: PropertyType; // Additional property};Parameters:MyCallableObject: The name of the type alias for the callable object.(parameter1: Type1, parameter2: Type2): Defines the parameters and their types for the callable aspect.ReturnType: Specifies the return type of the callable function.propertyName: PropertyType: An example of an additional property within the object.Greeting Function Using Call Signature TypeScript type GreetingFunction = { (name: string): string; // Call signature description: string; // Additional property }; const greet: GreetingFunction = (name: string) => { return `Hello, ${name}!`; }; greet.description = "A function to greet users"; console.log(greet("Alice")); console.log(greet.description); GreetingFunction defines a callable object that takes a string and returns a string.The greet function implements this call signature and includes an additional description property.Output:Hello, Alice!A function to greet users Calculator Using Call Signature TypeScript type Calculator = { (a: number, b: number): number; // Call signature operation: string; // Additional property }; const add: Calculator = (a: number, b: number) => a + b; add.operation = "Addition"; const multiply: Calculator = (a: number, b: number) => a * b; multiply.operation = "Multiplication"; console.log(`${add.operation}: ${add(5, 3)}`); console.log(`${multiply.operation}: ${multiply(5, 3)}`); Calculator defines a callable object that takes two number parameters and returns a number.The add and multiply functions implement this call signature with specific operations and include an operation property describing the operation.Output:Addition: 8Multiplication: 15Best Practices for Using TypeScript Call SignaturesClearly Define Parameter and Return Types: Ensure all call signatures specify explicit parameter and return types for better type safety.Include Descriptive Properties: Add properties that provide context or metadata about the callable object to enhance code readability.Use Consistent Naming Conventions: Adopt clear and consistent naming for callable objects and their properties to improve maintainability. Comment More infoAdvertise with us Next Article TypeScript Call Signatures A akshitsaxenaa09 Follow Improve Article Tags : JavaScript Web Technologies Geeks Premier League TypeScript Geeks Premier League 2023 +1 More Similar Reads TypeScript Construct Signatures TypeScript Construct Signatures define the shape of a constructor function, specifying the parameters it expects and the type of object it constructs. They use the new keyword in a type declaration to ensure the correct instantiation of classes or objects.Syntaxtype Constructor = new (param1: Type1, 3 min read TypeScript Interfaces Type TypeScript Interfaces Type offers an alternative method for defining an object's type, allowing for a distinct naming approach. Syntax:interface InterfaceName { property1: type1; property2?: type2; readonly property3: type3; // ... method1(): returnType1; method2(): returnType2; // ...}Parameters:in 2 min read TypeScript Optional Parameters in Callbacks In TypeScript, optional parameters in callbacks are parameters that may or may not be provided when the callback function is invoked. They are denoted by a ? after the parameter name, allowing for more flexible function calls without requiring all arguments.Syntaxtype MyCallback = (param1: string, p 2 min read TypeScript Assignability of Functions In this article, we will explore the concept of assignability of functions in TypeScript. Specifically, we will discuss how functions with a return type of void can be assigned to function types with other return types, including those that return values.Understanding AssignabilityIn TypeScript, fun 3 min read TypeScript Functions Type TypeScript function types define the structure of a function, including its parameter types and return type, ensuring consistent and type-safe usage.Help validate the types of parameters passed to a function.Ensure the function returns the expected type.Improve code clarity and prevent runtime error 6 min read Like