export type Name = string;
export type Email = string;
export type FooFunction = () => string; // (1)
export type TGetApi = { // (1)
(url: string, search?: string): Promise<string>;
};
export type TUser = {
readonly id: number; // (2)
readonly name: string;
email: Email;
receiveInfo: boolean;
active?: YesOrNo; // (3)
};
export type YesOrNo = "Y" | "N";
export type DayOfWeek = "μ" | "ν" | "μ" | "λͺ©" | "κΈ" | "ν " | "μΌ";
export enum DayOfTheWeek {"μ", "ν", "μ", "λͺ©", "κΈ", "ν ", "μΌ"}
export interface Color {
fontColor: string;
strokeColor: string;
borderColor: string;
backgroundColor: string;
}
export type Display = {
display: "none" | "block";
visibility: boolean;
opacity: number;
};
export type Geometry = {
width: number;
height: number;
padding: number;
margin: number;
};
export type TStyle = Color &
Display &
Geometry & {
tagName: string;
};
export type TOnlyBooleanValueObject = {
[prop: string]: boolean;
};
export type TGetApiArrow = (url: string, search?: string)
=> Promise<string>;
export type TGetApi = {
(url: string, search?: string): Promise<string>;
};
export interface IUser {
readonly id: number;
readonly name: Name;
email: string;
receiveInfo: boolean;
active: YesOrNo;
}
// (1)
export interface IUser {
address?: string;
}
export interface IUserProfile extends IUser {
profileImage: string;
github?: string;
twitter?: string;
}
// (2)
export interface Color {
fontColor: string;
strokeColor: string;
borderColor: string;
backgroundColor: string;
}
export type Display = {
display: "none" | "block";
visibility: boolean;
opacity: number;
};
export interface IStyle extends Color, Display {
tagName: string;
}
export interface IOnlyNumberValueObject {
[key: string]: number;
}
export interface IGetApi {
(url: string, search?: string): Promise<string>;
}
export interface IRectConstruct {
new (x: number, y: number, width: number, height: number): IRect;
}
class Rect implements allTypes.IRect {
id : number;
x: number;
y: number;
width: number;
height: number;
constructor(x: number, y: number, width: number, height: number){
this.id = Math.random() * 100000;
this.x = x;
this.y = y;
this.width = width;
this.height = height;
}
}
function createDefaultRect(cstor: allTypes.IRectConstruct){
return new cstor(0, 0, 100, 100);
}
const rect1 = new Rect(0, 0, 100, 20);
const rect2 = createDefaultRect(Rect);
ν¨μ€νΈμΊ νΌμ€ κΉλ―Όνμ νλ‘ νΈμλ μμΉ΄λ°λ―Έ