世界上最伟大的投资就是投资自己的教育
https://www.typescriptlang.org/docs/handbook/modules.html
index.ts
// import * as c from './classes';
// import { Shape, drawShapes } from './classes';
import Shape, { drawShapes } from './classes';
let a: Shape = {
draw: () => { }
}
drawShapes(a);
class Circle implements Shape {
draw(): void {
console.log("drawing Circle")
}
}
class Rectangle implements Shape {
draw(): void {
console.log('drawing Rectangle')
}
}
let circle = new Circle();
let rectangle = new Rectangle();
let c = drawShapes(circle);
classes.ts
export default interface Shape {
draw(): void;
}
// function drawShapes(shape: Shape): Shape {
// shape.draw();
// return shape;
// }
export function drawShapes<T extends Shape>(shape: T): T {
shape.draw();
return shape;
}
06:261Free诱人的 TypeScript 视频教程 #1 介绍
14:082Free诱人的 TypeScript 视频教程 #2 为什么要用 TypeScript
04:543Free诱人的 TypeScript 视频教程 #3 安装 TypeScript
05:574Pro诱人的 TypeScript 视频教程 #4 类型定义
12:155Pro诱人的 TypeScript 视频教程 #5 var、let、const
08:036Pro诱人的 TypeScript 视频教程 #6 数组 - Array
04:597Pro诱人的 TypeScript 视频教程 #7 元组 - Tuple
05:538Pro诱人的 TypeScript 视频教程 #8 函数 - Function - Arrow Function
05:359Pro诱人的 TypeScript 视频教程 #9 函数返回值类型 - void
08:2710Pro诱人的 TypeScript 视频教程 #10 函数 - 默认参数和可选参数
06:2111Pro诱人的 TypeScript 视频教程 #11 函数 - Rest Parameters
07:1412Pro诱人的 TypeScript 视频教程 #12 任意类型 - any
08:5513Pro诱人的 TypeScript 视频教程 #13 联合类型 - union type、null、undefined
09:3714Pro诱人的 TypeScript 视频教程 #14 类 - 面向对象 - class 介绍
11:4615Pro诱人的 TypeScript 视频教程 #15 面向对象 - 类 - 构造方法(constructor)- 方法(methods)
13:1016Pro诱人的 TypeScript 视频教程 #16 面向对象 - 继承和多态 - Inheritance and Polymorphism
15:2217Pro诱人的 TypeScript 视频教程 #17 面向对象 - 成员可见性 - Member visibility - public 和 private
22:5518Pro诱人的 TypeScript 视频教程 #18 面向对象 - 成员可见性 - Member visibility - 深入解析 private 和 protected 的异同
10:2419Pro诱人的 TypeScript 视频教程 #19 面向对象 - 成员可见性 - Member visibility - 深入探索 constructor
16:1220Pro诱人的 TypeScript 视频教程 #20 面向对象 - 静态属性和方法 - static - 深入探索成员可见性
03:4821Pro诱人的 TypeScript 视频教程 #21 面向对象 - 只读属性 - readonly
07:2222Pro诱人的 TypeScript 视频教程 #22 枚举类型 - enum
05:3023Pro诱人的 TypeScript 视频教程 #23 nodemon 和 ts-node
14:5624Pro诱人的 TypeScript 视频教程 #24 接口介绍 - Interfaces - 鸭子类型
07:0125Pro诱人的 TypeScript 视频教程 #25 接口使用 - Interfaces
06:1226Pro诱人的 TypeScript 视频教程 #26 接口 - 方法
12:0227Pro诱人的 TypeScript 视频教程 #27 类型别名 - type alias
16:2328Pro诱人的 TypeScript 视频教程 #28 实例演练类实现接口 - Class Types Implementing an interface
09:1929Pro诱人的 TypeScript 视频教程 #29 接口 - 可选属性 - Excess Property Checks
04:0330Pro诱人的 TypeScript 视频教程 #30 接口 - 只读属性
08:2531Pro诱人的 TypeScript 视频教程 #31 接口 - Function Types
11:3832Pro诱人的 TypeScript 视频教程 #32 结合接口详细谈谈类型断言 part 1
10:4433Pro诱人的 TypeScript 视频教程 #33 结合接口详细谈谈类型断言 part 2
05:3934Pro诱人的 TypeScript 视频教程 #34 接口 - 继承与实现多个接口
08:5535Pro诱人的 TypeScript 视频教程 #35 接口 - 接口继承类 - Interface Extending Classes
07:2036Free诱人的 TypeScript 视频教程 #36 接口 - Indexable Types part 1
14:1737Free诱人的 TypeScript 视频教程 #37 接口 - Indexable Types part 2
05:2438Pro诱人的 TypeScript 视频教程 #38 如何处理列表数据
09:2739Pro诱人的 TypeScript 视频教程 #39 类 - 抽象类(补充)
03:3540Pro诱人的 TypeScript 视频教程 #40 Class - Parameter Properties(补充)
09:1141Pro诱人的 TypeScript 视频教程 #41 Class - Accessors getters/setters(补充)
06:4242Pro诱人的 TypeScript 视频教程 #42 --noImplicitThis flag and arrow function
07:4543Pro诱人的 TypeScript 视频教程 #43 五种定义函数类型的方法
08:3144Pro诱人的 TypeScript 视频教程 #44 函数重载 - Function Overloading - part 1
09:2045Pro诱人的 TypeScript 视频教程 #45 函数重载 - Function Overloading - part 2
10:1046Pro诱人的 TypeScript 视频教程 #46 Type Guards part 1(typeof)
09:3947Pro诱人的 TypeScript 视频教程 #47 Type Guards part 2(instanceof)
07:3648Pro诱人的 TypeScript 视频教程 #48 Type Guards For null and undefined - --strictNullChecks
05:1949Pro诱人的 TypeScript 视频教程 #49 非空断言操作符 ! - Non-Null Assertion Operator !
07:4150Pro诱人的 TypeScript 视频教程 #50 never 类型 part 1
11:4451Pro诱人的 TypeScript 视频教程 #51 never 类型 part 2
06:5852Pro诱人的 TypeScript 视频教程 #52 Discriminated Unions
09:4053Pro诱人的 TypeScript 视频教程 #53 泛型 - generics - 为何要使用泛型
08:3554Free诱人的 TypeScript 视频教程 #54 泛型 - generics - 使用
06:2255Pro诱人的 TypeScript 视频教程 #55 泛型 - 在类中使用(简洁)
05:1656Pro诱人的 TypeScript 视频教程 #56 泛型 - 在函数中使用(简洁)
04:4957Pro诱人的 TypeScript 视频教程 #57 泛型 - 在接口中使用 part 1(简洁)
02:4758Pro诱人的 TypeScript 视频教程 #58 泛型 - Interfaces describing indexables part 2(简洁)
05:3159Pro诱人的 TypeScript 视频教程 #59 泛型 - OOPs style interfaces part 3(简洁)
07:4460Pro诱人的 TypeScript 视频教程 #60 扩展运算符 - Spread Operator(简洁)
03:2461Pro诱人的 TypeScript 视频教程 #61 用 keyof 来定义被允许的属性名称(简洁)
04:2762Pro诱人的 TypeScript 视频教程 #62 泛型 - Generic Constraints - 约束条件 part 1(65 集有补充)
05:3363Pro诱人的 TypeScript 视频教程 #63 泛型 - Generic Constraints - 约束条件 part 2(简洁)
02:3064Pro诱人的 TypeScript 视频教程 #64 泛型 - 类型别名(简洁)
05:1465Pro诱人的 TypeScript 视频教程 #65 泛型 - 约束 - 为什么要使用 extends(补充 62 集)
04:06Free诱人的 TypeScript 视频教程 #66 模块
06:0067Free诱人的 TypeScript 视频教程 #67 配置文件 tsconfig.json 使用指南
05:2168Pro诱人的 TypeScript 视频教程 #68 如何使用第三方库 part 1
05:5769Free诱人的 TypeScript 视频教程 #69 如何使用第三方库 part 2(完结)
▬▬▬▬▬▬ 联系我 👋 ▬▬▬▬▬▬
微信:qiuzhi99pro
b 站:https://space.bilibili.com/31152817
知乎:https://www.zhihu.com/people/rails365
Youtube:https://www.youtube.com/channel/UCA-Jkgr40A9kl5vsIqg-BIg
© 汕尾市求知科技有限公司 | 专业版网站 | 关于我们 | 在线学员:1140
粤公网安备 44152102000088号
| 粤ICP备19038915号