質問編集履歴
1
修正
test
CHANGED
File without changes
|
test
CHANGED
@@ -51,3 +51,35 @@
|
|
51
51
|
declare var Proxy: ProxyConstructor;
|
52
52
|
|
53
53
|
```
|
54
|
+
|
55
|
+
|
56
|
+
|
57
|
+
以下に修正して解決
|
58
|
+
|
59
|
+
```TypeScript
|
60
|
+
|
61
|
+
let target = {
|
62
|
+
|
63
|
+
name: 'Mike',
|
64
|
+
|
65
|
+
age: 17,
|
66
|
+
|
67
|
+
}
|
68
|
+
|
69
|
+
const handler: ProxyHandler<typeof target> = {
|
70
|
+
|
71
|
+
set: function(target, p: PropertyKey, value: any, receiver: any): boolean {
|
72
|
+
|
73
|
+
console.log(`${String(p)} is forbidden to change`)
|
74
|
+
|
75
|
+
return false
|
76
|
+
|
77
|
+
},
|
78
|
+
|
79
|
+
}
|
80
|
+
|
81
|
+
let proxy = new Proxy(target, handler)
|
82
|
+
|
83
|
+
proxy.age = 99
|
84
|
+
|
85
|
+
```
|