typescript interface

BackEnd_Ash.log·2021년 8월 11일
0

typescript

목록 보기
11/17

interfaces are usually used to define the necessary methods before implementing a class.

📌 define the type of object

📌 optional properties

optional properties are properties that are not required in an object

📌 readonly


readonly causes an error if you try to change the value

there is a property value called birthday in the p2 object, but there is no birthday in Person.

but you can type p2 into the Person type

this is because the p3 type is a larger type containing the type of p2

📌 index type

without defining the property name specifically in the interface ,
Defining only the type of a value is called an index type.

📌 Define a function type with interface

i defined the type of the function with interface, input the parameter on the left and the return type on the right

of course, the code above is the same.
it just shows that you can define a function type with an interface as well.

📌 implements interface

an interface can be implemented as a class.
if the property defined in the interface is not defined, an error occurs.

📌 interface extends interface

an interface can use extends to create a new interface.

📌 multiple interface extensions

multiple interfaces can be extended

multiple interfaces can be extended with cross-type

profile
꾸준함이란 ... ?

0개의 댓글