摘要: gitignore Specifies(指定) intentionally(有意地) untracked files to ignore 不跟踪指定的文件的变更状态 PATTERN(模式) FORMAT(格式) A blank line matches no files, so it can ser 阅读全文
posted @ 2021-09-07 18:43 蓦然回首! 阅读(86) 评论(0) 推荐(0) 编辑
摘要: 在 JSX 中嵌入表达式 声明一个名为 name 的变量,然后在 JSX 中使用它 const name = 'Josh Perez' const element = <h1>Hello, {name}</h1> 在 JSX 语法中,你可以在大括号内放置任何有效的 JavaScript表达式。 JS 阅读全文
posted @ 2021-05-15 12:57 蓦然回首! 阅读(47) 评论(0) 推荐(0) 编辑
摘要: Never never 是指没法正常结束返回的类型。 一个必定会报错或者死循环的函数会返回这样的类型。 // ⚠️never function errorNever(): never { throw new Error('error') } 永远没有相交的类型 // ⚠️never type Cro 阅读全文
posted @ 2021-04-25 09:48 蓦然回首! 阅读(278) 评论(0) 推荐(0) 编辑
摘要: Configure the path mapping(路径映射) in jsconfig.json { "compilerOptions": { "baseUrl": ".", "paths": { "@/*": ["./src/*"] "t/*": ["./test/*"] } } } 文件结构 阅读全文
posted @ 2021-04-23 09:45 蓦然回首! 阅读(586) 评论(0) 推荐(0) 编辑
摘要: Omit 描述:Omit 构造一个具有 T 属性的类型,K 类型除外。 type Omit<T, K extends keyof any> = Pick<T, Exclude<keyof T, K>>; 示例 interface Person { name: string age: number g 阅读全文
posted @ 2021-04-22 11:34 蓦然回首! 阅读(60) 评论(0) 推荐(0) 编辑
摘要: Partial 描述:Partial 将类型 T 的所有属性标记为可选属性 type Partial<T> = { [P in keyof T]?: T[P]; }; 示例 interface Person { name: string age: number } type PersonPartia 阅读全文
posted @ 2021-04-21 19:04 蓦然回首! 阅读(214) 评论(0) 推荐(0) 编辑
摘要: 交叉类型是将多个类型合并为一个类型。 这让我们可以把现有的多种类型叠加到一起成为一种类型,它包含了所需的所有类型的特性。 示例 interface Person { name: string age: number } interface Student { school: string } // 阅读全文
posted @ 2021-04-19 22:23 蓦然回首! 阅读(1059) 评论(0) 推荐(1) 编辑
摘要: 泛型(Generics) 是指在定义函数、接口或类的时候,不预先指定具体的类型,而在使用的时候再指定类型的一种特性。 示例 假如我们需要一个 输入数字 ⇒ 返回数字 的函数 function echoValue(args: number): number { return args } // ✅正确 阅读全文
posted @ 2021-04-16 21:59 蓦然回首! 阅读(121) 评论(0) 推荐(0) 编辑
摘要: 「类型 + 方括号」表示法 示例 // ✅正确 const nums1: number[] = [1, 2, 3, 4] // ❌错误 // Type 'number' is not assignable to type 'string'. // 数组的项中不允许出现其它的类型 const nums 阅读全文
posted @ 2021-04-15 09:20 蓦然回首! 阅读(95) 评论(0) 推荐(0) 编辑
摘要: 函数声明 示例 function sum(x: number, y: number): number { return x + y } // ✅正确 sum(2, 4) // ❌错误 // Expected 2 arguments, but got 3. sum(2, 4, 5) // ❌错误 // 阅读全文
posted @ 2021-04-14 09:31 蓦然回首! 阅读(621) 评论(0) 推荐(0) 编辑