In this post, we will learn how to fix the error “Type ‘#’ is missing the following properties from type ‘##'”. Now, let’s follow some steps. I will show you how to fix it.
The cause of this error
The error “Type ‘#’ missing the following properties from type ‘##'” occurs when you use an object but inside it does not have the previously declared included properties or lacks properties of the object.
Let me show you when the error occurs:
Example 1:
class Student { name: string; age: number; address: string } const student: Student = { };
Output:
Error: Type '{}' is missing the following properties from type 'Student': name, age, address ts(2739)
Example 2:
class Student { name: string; age: number; address: string } function getStudentInformation(student: Student) { return student; } getStudentInformation({});
Output:
Argument of type '{}' is not assignable to parameter of type 'Student'.
Type '{}' is missing the following properties from type 'Student': name, age, address
In both examples, we set three types in the Student class but when we declare the student object there are no properties in it. The output we are expecting are ‘name’, ‘age’ and ‘address’ properties.
How to fix the error “Type ‘#’ is missing the following properties from type ‘##'”?
Method 1: Using Optional Mark ‘?’
Much of the time, we’ll locate ourselves dealing with objects that may have a property set. In this case, we can mark these properties as optional by adding a question mark ‘?’ at the end of the properties name.
For instance below the code:
class Student { name?: string; age?: number; address?: string } const student: Student = { }; function getStudentInformation(student: Student) { return student; } getStudentInformation({});
‘name’, ‘age’, ‘address’ have been using question mark (?). No error message occurs because properties are not required. But they also aren’t needed.
Method 2: Setting default parameter for each properties
For example:
class Student { name: string; age: number; address: string } const student: Student = { name: '', age: 0, address: '' };
Or, if you want to call a function that has an object, set the default parameter by the below example:
class Student { name: string; age: number; address: string; } function getStudentInformation(student: Student = {name: '', age: 0, address: ''}) { return student; } getStudentInformation();
Summary
The error “Type ‘#’ missing the following properties from type ‘##'” occurs when you use an object but inside it does not have the previously declared included properties or lacks properties of the object. After reading this post, I hope you will learn how to fix this error. I hope this tutorial is helpful to you. Happy coding.
Maybe you are interested:
- Type is not assignable to type ‘never’ in TypeScript
- Type ‘null’ is not assignable to type in TypeScript
- Type ‘string or undefined’ is not assignable to type string

My name is Robert. I have a degree in information technology and two years of expertise in software development. I’ve come to offer my understanding on programming languages. I hope you find my articles interesting.
Job: Developer
Name of the university: HUST
Major: IT
Programming Languages: Java, C#, C, Javascript, R, Typescript, ReactJs, Laravel, SQL, Python