老师我不加export怎么也不报错

type Point = {
x: number;
y: number;
z: number;
};
// type ReadonlyPoint = {
// readonly x: number;
// readonly y: number;
// readonly z: number;
// };
// 类型映射 [item in Union]:Output
type ReadonlyPoint0={
readonly [item in "x"|"y"|"z"]:number
}
type ReadonlyPoint1 = {
readonly [item in keyof Point]: Point[item];
};
// type ReadOnly<T> = { readonly [item in keyof T]: T[item]; }
// 使用泛型,不止Point这一个类型可用
type ReadOnly<T> = {
readonly [item in keyof T]: T[item];
};
// const center: Point = {
const center: ReadOnly<Point> = {
x: 0,
y: 0,
z: 0,
};
center.x = 100;8
收起
正在回答 回答被采纳积分+1
1回答

恭喜解决一个难题,获得1积分~
来为老师/同学的回答评分吧
0 星