Actually, there appears to now be a simple way. The following code works in TypeScript 1.5:

function sayName({ first, last = 'Smith' }: {first: string; last?: string }): void {
  const name = first + ' ' + last;
  console.log(name);
}

sayName({ first: 'Bob' });

The trick is to first put in brackets what keys you want to pick from the argument object, with key=value for any defaults. Follow that with the : and a type declaration.

This is a little different than what you were trying to do, because instead of having an intact params object, you have instead have dereferenced variables.

If you want to make it optional to pass anything to the function, add a ? for all keys in the type, and add a default of ={} after the type declaration:

function sayName({first='Bob',last='Smith'}: {first?: string; last?: string}={}){
    var name = first + " " + last;
    alert(name);
}

sayName();
Answer from jpadvo on Stack Overflow
🌐
TypeScript Tutorial
typescripttutorial.net › home › typescript tutorial › typescript default parameters
TypeScript Default Parameters
June 2, 2020 - Use default parameter syntax parameter:=defaultValue if you want to set the default initialized value for the parameter. Default parameters are optional.
🌐
Mimo
mimo.org › glossary › typescript › default-parameter
TypeScript Default Parameter: Syntax, Usage, and Examples
Define a default parameter by assigning a value directly in the function definition. When an argument is missing, TypeScript automatically assigns the default value.
🌐
MDN Web Docs
developer.mozilla.org › en-US › docs › Web › JavaScript › Reference › Functions › Default_parameters
Default parameters - JavaScript | MDN
This function will print the value of the parameter a, because the variable var a is hoisted only to the top of the scope created for the function body, not the parent scope created for the parameter list, so its value is not visible to b. ... The default parameter allows any expression, but you ...
🌐
typescriptlang.org
typescriptlang.org › docs › handbook › 2 › functions.html
TypeScript: Documentation - More on Functions
description = "default description"; doSomething( myFunc);Try · Note that the syntax is slightly different compared to a function type expression - use : between the parameter list and the return type rather than =>. JavaScript functions can also be invoked with the new operator. TypeScript refers to these as constructors because they usually create a new object.
🌐
Medium
medium.com › @kidaneberihuntse › simplifying-typescript-functions-with-default-parameter-values-d07bc6c54fa3
Simplifying TypeScript Functions with Default Parameter Values | by Kidu BT | Medium
March 29, 2024 - Let’s dive into how these features work together to streamline function declarations. To set a default value for a function parameter in TypeScript, you simply assign the default value directly in the parameter declaration.
Find elsewhere
🌐
TutorialsPoint
tutorialspoint.com › typescript › typescript_default_parameters.htm
TypeScript - Default Parameters
In TypeScript, we can assign the function parameters some values by default. Such parameters can be explicitly passed values. These parameters are known as default parameters. When a function is called with missing arguments, or argument with
🌐
Codefinity
codefinity.com › courses › v2 › a5c23211-8dc2-4c4a-9a83-07a51e843ab6 › 22ee44ac-3952-4715-93f5-a0e487b41d5a › 2514af82-5f65-42e6-9010-4fcdb9dc7dab
Learn Default Values | Functions
Default values are often used alongside or in place of optional parameters. You can set a default value for a parameter, and if you don't specify a value for that parameter when calling the function, it will be initialized with the default value.
🌐
Nicolas Charpentier
charpeni.com › blog › be-careful-with-javascript-default-parameters
Be Careful With JavaScript Default Parameters! | Nicolas Charpentier
November 3, 2022 - By using the default parameter to true on showHeader, we're saying that we're expecting a boolean, but if no value is passed, we want to set showHeader to true by default. We're also using strict checks to make sure we're not getting any unexpected values as TypeScript tells us we can only get a boolean out of showHeader.
🌐
Skypoint
skypoint.ai › home › typescript default parameters and destructuring as a substitute for named parameters
TypeScript Default Parameters and Destructuring As a Substitute for Named Parameters - Skypoint
September 23, 2022 - JavaScript, as well as TypeScript, doesn’t support this kind of assignment in a function call. Instead I’ll need to provide a value for all the parameters preceding currency. ... When I pass a parameter an undefined value JavaScript will use the default value for that parameter.
🌐
Convex
convex.dev › core concepts › functions & methods › optional parameters
Optional Parameters | TypeScript Guide by Convex
Parameters with default values are already optional, so the ? is redundant and not allowed. TypeScript requires all optional parameters to come last.
🌐
HowToDoInJava
howtodoinjava.com › home › typescript › typescript optional and default parameters
TypeScript Optional and Default Parameters (with Examples)
June 23, 2023 - Default parameters help by providing sensible or commonly used values for certain parameters, but still allow flexibility to override those default values when necessary. TypeScript allows assigning a default value to a parameter if no value ...
🌐
Tim Mousk
timmousk.com › blog › typescript-default-parameter
How To Set A Default Parameter In TypeScript? – Tim Mouskhelichvili
March 6, 2023 - In this example, the year parameter is an optional parameter that fallbacks to the current year if it has no value. TypeScript also supports default values when destructuring an object inside a function definition.
🌐
GeeksforGeeks
geeksforgeeks.org › typescript › typescript-optional-parameters
TypeScript Optional Parameters - GeeksforGeeks
January 22, 2025 - Provide Default Values When Appropriate: Assign default values to optional parameters to ensure predictable behavior when arguments are omitted. Use Union Types for Flexibility: Consider using union types for optional parameters to clearly specify the types that are allowed, enhancing type safety. Comment · Article Tags: Article Tags: TypeScript ·
🌐
Reddit
reddit.com › r/typescript › is there a way to have a default value for an object argument passed to a function?
r/typescript on Reddit: Is there a way to have a default value for an object argument passed to a function?
January 7, 2026 -
type OrderInfo = {
    quantity: number;
    productID: number;
    price: number;
    onSale: boolean
}


function order(orderInfo: OrderInfo): void { // I want onSale to default to true


}


order({quantity: 5, productID: 11, price: 5})

I want onSale to default to true in the order function so I don't have to mention it when calling it.

https://www.typescriptlang.org/play/?#code/C4TwDgpgBA8gTgEwnAkgOwGYHsoF4oDeAUFKVAI4CuAhmsAJagBcUalAtgEbIDcJZYOFgSUAxsBQARFmy69+pQfVEQZHbnD5koWNAGVqAG1VROWLMdpEAvkSIZKacfV07EyABRZ3qTFhbwSL7YAJQsAG5Y9AiEdrZE3kEeBFS0DMxQAKwANFCCwmIS0lAAjCW5SiosmdYhUAD09VAoUADuaTr6RtDAOEgY1JSGwFC9o3CUEHZAA

🌐
Marius Schulz
mariusschulz.com › blog › generic-parameter-defaults-in-typescript
Generic Parameter Defaults in TypeScript — Marius Schulz
November 22, 2020 - Enter generic parameter defaults. Starting with TypeScript 2.3, we can optionally add a default type to each of our generic type parameters.
🌐
Mimo
mimo.org › glossary › typescript › optional-parameter
TypeScript Optional Parameter: Syntax, Usage, and Examples
You can provide a default value for an optional parameter. If you don’t pass an argument, TypeScript uses the default value.
🌐
HackerNoon
hackernoon.com › how-to-use-default-parameters-in-typescript
How to Use Default Parameters in TypeScript | HackerNoon
August 21, 2022 - When we talk about default parameters, we are talking about giving arguments values that should be used, if that argument is undefined.
🌐
EDUCBA
educba.com › home › software development › software development tutorials › typescript tutorial › typescript default parameter
TypeScript default parameter | Learn How does default parameter work?
April 6, 2023 - The default parameter in TypeScript is used to assign some default value to the variable. In JavaScript, we have this provision not to pass the required argument to the called function because it internally manages, But in TypeScript, we cannot ...
Address   Unit no. 202, Jay Antariksh Bldg, Makwana Road, Marol, Andheri (East),, 400059, Mumbai