You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

23 lines
405 B

// 两个类的兼容性演示:
class Point {
x: number
y: number
}
class Point2D {
x: number
y: number
}
const p: Point = new Point2D()
class Point3D {
x: number
y: number
z: number
}
// 对象成员多的可以赋值给对象成员少的,Point3D 的成员多过 Point,所以可以赋值。
const p1: Point = new Point3D()
// 对象成员少的不能给对象多的