TS基础 -> 爬虫 -> TS语法进阶 -> 接口 -> TS高级语法 -> 重构 -> 开发
TS: JS的超级, 需要编辑器编译为js
静态类型
let b = 123
b = '123'
let b: number = 123;
type Person {
name: String
}
class Person {
name: String
}
const teacher: Person = {
name: "Jack"
}
编译为:
接口
interface Person {
name: String,
age?: Number,
[propName: string]: any,
say(): string // 方法
}
// 函数类型
interface SayHi {
}
类应用接口
class User implements Person {
name = 'Jack'
say() {
return 'hello'
}
}
接口继承
interface Teacher extends Person {
teach(): string
}