Can I tell the interface to default the properties I don't supply to null? What would let me do this

No. You cannot provide default values for interfaces or type aliases as they are compile time only and default values need runtime support

Alternative

But values that are not specified default to undefined in JavaScript runtimes. So you can mark them as optional:

interface IX {
  a: string,
  b?: any,
  c?: AnotherType
}

And now when you create it you only need to provide a:

let x: IX = {
    a: 'abc'
};

You can provide the values as needed:

x.a = 'xyz'
x.b = 123
x.c = new AnotherType()
Answer from basarat on Stack Overflow
🌐
Mimo
mimo.org › glossary › typescript › interface
TypeScript Interface: Syntax, Usage, and Examples
Interfaces do not support default values directly, but you can use a factory function.
Discussions

Interface Default Values
Suggestion This will be a very useful feature If we could provide default values for interfaces , In Kotlin you can already do this using interface Y { val x : Int get() = 5 } There's a stackov... More on github.com
🌐 github.com
3
July 12, 2023
Defaulting Unspecified Interface Properties to Null in TypeScript - Ask a Question - TestMu AI Community
I have the following TypeScript interface: interface IX { a: string; b: any; c: AnotherType; } I declare a variable of this type and initialize all the properties with default values: let x: IX = { a: … More on community.testmuai.com
🌐 community.testmuai.com
0
July 25, 2024
Is there a way to have a default value for an object argument passed to a function?
Destructuring with default value is more readable in most cases. If you don’t want to destructure everything you can do: function order(orderInfo: OrderInfo) { const {onSale = true} = orderInfo; } Then you don’t lose the original object More on reddit.com
🌐 r/typescript
26
6
January 7, 2026
Interface hint helper showing values that will be used defaultly ?

Interfaces, i think at least, is intended for example to define what properties and methods must be defined, their types and their eventual return values. It is then up to each class that implementes the interface to handle exactly how. The fictive Interface EmailSendingInterface does for example not dictate what api to call or how error handling should be implemented, but rather what methods and params other programs will use to utilize a class that implements the EmailSendingInterface.

Fictive class MailgunService might implememt the EmailSendingInterface interface, but the interface does not all care how the class sends emails (or if it even does). It just says hey, if they claim to conform to me they will have a SendEmail( sender: string, content: string) method. MailgunService might implement that method using mailgun api, but MockSender might implement that by console logging the parameters and returning an OK to the calling class.

Does it make it clearer why interfaces do not dictate values and implementations but only conformity rules for the actual implementating classes?

More on reddit.com
🌐 r/typescript
6
2
October 15, 2020
🌐
typescriptlang.org
typescriptlang.org › docs › handbook › 2 › objects.html
TypeScript: Documentation - Object Types
We can also read from those properties - but when we do under strictNullChecks, TypeScript will tell us they’re potentially undefined. ... In JavaScript, even if the property has never been set, we can still access it - it’s just going to give us the value undefined. We can just handle undefined specially by checking for it. ... Note that this pattern of setting defaults for unspecified values is so common that JavaScript has syntax to support it.
🌐
DEV Community
dev.to › qpwo › documenting-default-interface-values-in-typescript-or-trying-to-3b01
Documenting default interface values in typescript, or trying to... - DEV Community
May 9, 2022 - Surely the declaration file will point your numerous future library users to this class, and if they examine it with a careful eye, they will be able to determine the default values of your optional arguments. You hold your breath, run tsc, and open index.d.ts · interface PartialOptions { id: string excellence: number color?: string isAdmin?: boolean } export declare function addUser(options: PartialOptions): void export {}
🌐
TSDoc
tsdoc.org › pages › tags › defaultvalue
@defaultValue | TSDoc
This block tag is used to document the default value for a field or property, if a value is not assigned explicitly. This tag should only be used with fields or properties that are members of a TypeScript class or interface.
🌐
GitHub
github.com › microsoft › TypeScript › issues › 54979
Interface Default Values · Issue #54979 · microsoft/TypeScript
July 12, 2023 - This feature would agree with the rest of TypeScript's Design Goals. ... The best syntax would be , This suggests x default value is "y" and when x value is not given "y" is used · export interface AccordionColors { x : string = "y" }
Author   wakaztahir
Find elsewhere
🌐
EDUCBA
educba.com › home › software development › software development tutorials › typescript tutorial › typescript interface default value
TypeScript Interface Default Value | Learn the Syntax and Examples
April 18, 2023 - interface EDUCBA { courseName:string, courseDuration:number, courseCode:number, loginAccess: number, supplementaryCourse: string, greetings: ()=>string } Moving further these default values are given data as, var course1:EDUCBA = { courseName:"Data Science", courseDuration:22, courseCode: 22435, supplementaryCourse: "Data Analyst", loginAccess: 10, greetings: ():string =>{return "Heyoo!
Address   Unit no. 202, Jay Antariksh Bldg, Makwana Road, Marol, Andheri (East),, 400059, Mumbai
🌐
Medium
rare.medium.com › setting-default-values-in-typescript-ac7f31482996
Setting Default Values in TypeScript | by rare. | Medium
May 14, 2024 - Sometimes it is wise to stick to default values for parameters in TypeScript / JavaScript functions. I mainly use two approaches in my daily life to handle this. ... Lots of little default values to pick from. ... interface Superhero { name?: string; skill?: string; isSmart?: boolean; } const defaultSuperhero: Superhero = { name: 'Unknown Hero', skill: 'Unknown Skill', isSmart: false, }; function describeSuperhero(superhero: Superhero = defaultSuperhero): void { const { name, skill, isSmart } = superhero; console.log(`Superhero: ${name}. Skill: ${skill}. Smart: ${isSmart}`); } // Example usage: describeSuperhero(); // Output: Superhero: Unknown Hero.
🌐
SPGuides
spguides.com › set-default-values-in-typescript-interfaces
How to Set Default Values in TypeScript Interfaces?
March 26, 2025 - While TypeScript interfaces do not support default values natively, you can achieve default values by combining interfaces with functions or classes.
🌐
LogRocket
blog.logrocket.com › home › understanding and using interfaces in typescript
Understanding and using interfaces in TypeScript - LogRocket Blog
October 17, 2024 - It suggests that these properties cannot be modified after they are initialized with some value. While interfaces in TypeScript are excellent for defining the shape of objects, they cannot directly specify default values for properties.
🌐
Tim Mousk
timmousk.com › blog › typescript-interface-default-value
How To Set Up A TypeScript Interface Default Value? – Tim Mouskhelichvili
March 27, 2023 - By using the TypeScript pick utility type, we can select properties from an interface and provide default values for them.
🌐
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.
🌐
Bobby Hadz
bobbyhadz.com › blog › typescript-interface-default-values
How to set up TypeScript interface Default values | bobbyhadz
February 26, 2024 - Use the Pick utility type to only select the properties that have default values. Use the spread syntax to unpack the rest of the properties after the defaults when creating an object.
🌐
Graphite
graphite.com › guides › typescript-interfaces
Understanding interfaces in TypeScript
... In this example, Customer extends two discrete interfaces, combining the properties of Person and Contact. Interfaces themselves do not hold default values in TypeScript; they are strictly for typing.
🌐
Quora
quora.com › What-are-the-default-values-of-a-Typescript-Interface
What are the default values of a Typescript Interface? - Quora
Answer (1 of 2): An interface describes the shape of data and isn’t data itself. If you compile a .ts file that only has an interface in it, it won’t generate any code. So, interfaces have no data and no default value.
🌐
GitHub
github.com › bobbyhadz › typescript-interface-default-values
GitHub - bobbyhadz/typescript-interface-default-values: A repository for an article at https://bobbyhadz.com/blog/typescript-interface-default-values
A repository for an article at https://bobbyhadz.com/blog/typescript-interface-default-values - bobbyhadz/typescript-interface-default-values
Author   bobbyhadz
🌐
TestMu AI Community
community.testmuai.com › ask a question
Defaulting Unspecified Interface Properties to Null in TypeScript - Ask a Question - TestMu AI Community
July 25, 2024 - I have the following TypeScript interface: interface IX { a: string; b: any; c: AnotherType; } I declare a variable of this type and initialize all the properties with default values: let x: IX = { a: 'abc', b: null, c: null }; Later, I assign actual values to these properties in an init function: x.a = 'xyz'; x.b = 123; x.c = new AnotherType(); I don’t like having to specify default null values for each property when declaring the object, especially since they will...
🌐
GeeksforGeeks
geeksforgeeks.org › typescript › typescript-generic-parameter-defaults
TypeScript Generic Parameter Defaults - GeeksforGeeks
September 15, 2025 - TypeScript Generic Parameter Defaults allow us to specify default values for generic type parameters.