Horje
type alias in typescript Code Example
type alias in typescript
type StringAlias = string;
type NumberAlias = number;
// aliases for 'normal' types

type SixAlias = 6;         
type MyFavouriteFood = "burger"; 
// aliases for 'literal' types
// these are usually useless on their own

type Food = MyFavouriteFood | "pizza" | "pasta" | "salad";
// they get useful when you combine them:
// a Food can be one of these choices.

type Foods = Food[];
// this is an alias for an array of Foods.

type SuccessfulResponse = {
	message: string,
  	statusCode: number,
  	attachment?: string,
	preferredFoods?: Foods,
}                          
// Now we define a SuccessfulResponse type as the type of a
// JS literal object with two required and two optional attributes.
// Note that you could also use an interface in this case.

type SuccessfulResponseHandler = (res: SuccessfulResponse) => void;
// This is a type alias for a function.


// tl;dr: You can alias every type in TypeScript and chain them.
// This is very useful for reusability and readability.




Typescript

Related
remove dots and commas java Code Example remove dots and commas java Code Example
ts new example Code Example ts new example Code Example
whcih commands lets you an ip adress log Code Example whcih commands lets you an ip adress log Code Example
typescript allow object subset of interface Code Example typescript allow object subset of interface Code Example
les différents types de cours Code Example les différents types de cours Code Example

Type:
Code Example
Category:
Coding
Sub Category:
Code Example
Uploaded by:
Admin
Views:
8