Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Latest commit

 

History

History
History
47 lines (40 loc) · 1.72 KB

File metadata and controls

47 lines (40 loc) · 1.72 KB
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
import { __TS__CloneDescriptor } from "./CloneDescriptor";
import { __TS__DescriptorGet } from "./DescriptorGet";
import { __TS__DescriptorSet } from "./DescriptorSet";
const getmetatable = _G.getmetatable;
function descriptorIndex(this: any, key: string): void {
return __TS__DescriptorGet.call(this, getmetatable(this), key);
}
function descriptorNewIndex(this: any, key: string, value: any): void {
return __TS__DescriptorSet.call(this, getmetatable(this), key, value);
}
// It's also used directly in class transform to add descriptors to the prototype
export function __TS__SetDescriptor(
this: void,
target: any,
key: any,
desc: PropertyDescriptor,
isPrototype = false
): void {
let metatable = isPrototype ? target : getmetatable(target);
if (!metatable) {
metatable = {};
setmetatable(target, metatable);
}
// When setting a descriptor on an instance (not a prototype), ensure it has
// its own metatable so descriptors are not shared across instances.
// See: https://github.com/TypeScriptToLua/TypeScriptToLua/issues/1625
if (!isPrototype && !rawget(metatable, "_isOwnDescriptorMetatable")) {
const instanceMetatable: any = {};
instanceMetatable._isOwnDescriptorMetatable = true;
setmetatable(instanceMetatable, metatable);
setmetatable(target, instanceMetatable);
metatable = instanceMetatable;
}
const value = rawget(target, key);
if (value !== undefined) rawset(target, key, undefined);
if (!rawget(metatable, "_descriptors")) metatable._descriptors = {};
metatable._descriptors[key] = __TS__CloneDescriptor(desc);
metatable.__index = descriptorIndex;
metatable.__newindex = descriptorNewIndex;
}
Morty Proxy This is a proxified and sanitized view of the page, visit original site.