Skip to content

Commit e024d4b

Browse files
committed
Update README.md
1 parent fcab35e commit e024d4b

File tree

1 file changed

+20
-10
lines changed

1 file changed

+20
-10
lines changed

README.md

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -175,11 +175,16 @@ Yes, the code is valid. A class declaration creates two things: a type represent
175175
<b><a href="#">↥ back to top</a></b>
176176
</div>
177177

178-
## Q. Explain how and why we could use property decorators in TS?
178+
## Q. Explain decorators in TS?
179179

180-
Decorators can be used to modify the behavior of a class or become even more powerful when integrated into a framework. For instance, if your framework has methods with restricted access requirements (just for admin), it would be easy to write an @admin method decorator to deny access to non-administrative users, or an @owner decorator to only allow the owner of an object the ability to modify it.
180+
Decorators can be used to modify the behavior of a class or become even more powerful when integrated into a framework. For instance, if your framework has methods with restricted access requirements (just for admin), it would be easy to write an `@admin` method decorator to deny access to non-administrative users, or an `@owner` decorator to only allow the owner of an object the ability to modify it.
181+
182+
**Example:**
181183

182184
```ts
185+
/**
186+
* Decorators
187+
*/
183188
class Employee {
184189
get() { }
185190
post() { }
@@ -196,9 +201,21 @@ class Employee {
196201
<b><a href="#">↥ back to top</a></b>
197202
</div>
198203

199-
## Q. What is the difference between "interface vs type" statements?
204+
## Q. What is the difference between interface and type statements?
205+
206+
|Interface |Type |
207+
|----------|-------|
208+
|An interface declaration always introduces a named object type. |A type alias declaration can introduce a name for any kind of type, including primitive, union, and intersection types.|
209+
|An interface can be named in an extends or implements clause. |Type alias for an object type literal cannot be named in an |extends or implements clause.|
210+
|Interfaces create a new name that is used everywhere. |Type aliases don\'t create a new name.|
211+
|An interface can have multiple merged declarations. |Type alias for an object type literal cannot have multiple merged declarations.|
212+
213+
**Example:**
200214

201215
```ts
216+
/**
217+
* Interface vs Type
218+
*/
202219
interface X {
203220
a: number
204221
b: string
@@ -210,13 +227,6 @@ type X = {
210227
};
211228
```
212229

213-
|interface |type |
214-
|----------|-------|
215-
|An interface declaration always introduces a named object type. | A type alias declaration can introduce a name for any kind of type, including primitive, union, and intersection types.|
216-
|An interface can be named in an extends or implements clause. |Type alias for an object type literal cannot be named in an |extends or implements clause.|
217-
|Interfaces create a new name that is used everywhere. |Type aliases don't create a new name.|
218-
|An interface can have multiple merged declarations. |Type alias for an object type literal cannot have multiple merged declarations.|
219-
220230
<div align="right">
221231
<b><a href="#">↥ back to top</a></b>
222232
</div>

0 commit comments

Comments
 (0)