当前位置: 首页 > news >正文

安阳哪里有学做网站的学校福州网站优化公司

安阳哪里有学做网站的学校,福州网站优化公司,WordPress瀑布流图片站,中国专门做生鲜的网站前言 TypeScript 越来越火&#xff0c;现在很多前端团队都使用它&#xff0c;因此咱们前端码农要想胜任以后的前端工作&#xff0c;就要更加熟悉它。 入门练手题 interface A {x: number;y: number; }type T Partial<A>;const a: T { x: 0, y: 0 }; const b: T { …

前言

TypeScript 越来越火,现在很多前端团队都使用它,因此咱们前端码农要想胜任以后的前端工作,就要更加熟悉它。
在这里插入图片描述

入门练手题

interface A {x: number;y: number;
}type T = Partial<A>;const a: T = { x: 0, y: 0 };
const b: T = { x: 0 };
const c: T = { y: 0 };
const d: T = {};type MyPartial<T> = {[P in keyof T]?: T[P];
};interface B {x?: number;y: number;
}type T0 = Required<B>;const a0: T0 = { x: 0, y: 0 };type MyRequired<T> = {[P in keyof T]-?: T[P];
};interface C {x?: number;y: number;
}type T1 = Readonly<C>;const a1: T1 = { x: 0, y: 0 };// a1.x=1type MyReadonly<T> = {readonly [P in keyof T]: T[P];
};interface Cat {age: number;gender: string;
}type CatName = "seraph" | "ashe" | "ahri";const cats: Record<CatName, Cat> = {seraph: { age: 10, gender: "male" },ashe: { age: 5, gender: "female" },ahri: { age: 16, gender: "female" },
};/* 在 TypeScript 中,当你看到 K extends keyof any 这样的表达时,
它的作用是约束类型 K 为一个有效的类型,可以作为对象的键。
这里的 keyof any 是指所有可能的 JavaScript 值的键的联合类型。
简单来说,keyof any 通常等价于 string | number | symbol ,
因为在 JavaScript 中,对象的键可以是这三种类型。
你可以使用 string,number 或者 symbol 作为对象属性的键。 */type MyRecord<K extends keyof any, T> = {[P in K]: T;
};interface Todo {title: string;description: string;done: boolean;
}type TodoPreview = Pick<Todo, "title" | "done">;const todo: TodoPreview = {title: "play games",done: false,
};type MyPick<T, K extends keyof T> = {[P in K]: T[P];
};type E0 = Exclude<"a" | "b", "a">;type E1 = Exclude<string | number | (() => void), Function>;type MyExclude<T, U> = T extends U ? never : T;interface Todos {title: string;desc: string;done: boolean;no: number;
}type TodoPre = Omit<Todos, "desc">;const todopre: TodoPre = {title: "play",done: false,no: 2,
};type TodoInfo = Omit<Todos, "desc" | "no">;const todoInfo: TodoInfo = {title: "play",done: false,
};type MyOmit<T, K extends keyof any> = Pick<T, Exclude<keyof T, K>>;type E = Extract<"a" | "b", "a" | "f">;type E3 = Extract<string | number | (() => void), Function>;type MyExtrat<T, U> = T extends U ? T : never;declare function f(args: { a: number; b: string }): void;type P0 = Parameters<() => string>; // []type P1 = Parameters<(s: string) => void>; // [s: string]type P2 = Parameters<<T>(arg: T) => T>; // [arg: unknown]type P3 = Parameters<typeof f>;type MyParameters<T extends (...args: any) => any> = T extends (...args: infer P
) => any? P: never;type R = ReturnType<() => void>;const add = (x: number, y: number): number => {return x + y;
};type R1 = MyReturnType<typeof add>;type MyReturnType<T extends (...args: any) => any> = T extends (...args: any
) => infer R? R: any;
http://www.tj-hxxt.cn/news/127159.html

相关文章:

  • 外包和劳务派遣哪个好淘宝seo搜索引擎原理
  • 什么网站可以做字体效果网络推广服务合同
  • 做销售网站多少钱今天百度数据
  • wordpress特定文章小工具7个湖北seo网站推广策略
  • 现在最常用网站开发工具如何成为app推广代理
  • 来广营做网站软文广告是什么
  • 个人网站建设教程外链群发软件
  • 上海浦东新区做网站搜索热度查询
  • 苏州市吴江区建设局网站网络营销好找工作吗
  • 免费网站建设必找186一6159一6345宁波seo网络推广选哪家
  • 柳州建设网站经济适用房表格百度一下官方网址
  • 有域名有空间如何做网站唐山seo优化
  • 淄博市淄川疫情最新情况seo顾问赚钱吗
  • 中文 wordpress 主题seo公司培训课程
  • 做网盘搜索网站合法吗加拿大搜索引擎
  • 做电影资源网站服务器怎么选百度一下网页入口
  • 个人网站制作说明网络营销的真实案例分析
  • 金华网站制作价格网站排名seo软件
  • 做淘宝门头的网站百度指数查询
  • 专业的做网站软件qq群引流推广软件
  • 呼和浩特网站建设哪家最便宜浙江seo博客
  • 邢台营销型网站建设网站优化seo怎么做
  • 投诉网站怎么做seo综合查询什么意思
  • 企业微信开发者工具游戏优化大师官网
  • 个人备案的网站可以做商城吗东莞优化怎么做seo
  • 网站开发工程师岗位职责seo还有哪些方面的优化
  • 网络营销网站建设诊断报告深圳关键词seo
  • 公司网站开发费用怎么做账国际新闻最新消息10条
  • 中铁中基建设集团网站seo基础
  • 网站建设收获百度一下百度一下你就知道