Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add class private field helper methods #79

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions tslib.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,5 @@ export declare function __asyncValues(o: any): any;
export declare function __makeTemplateObject(cooked: string[], raw: string[]): TemplateStringsArray;
export declare function __importStar<T>(mod: T): T;
export declare function __importDefault<T>(mod: T): T | { default: T };
export declare function __classPrivateFieldSet<T extends object, V>(receiver: T, privateMap: WeakMap<T, TypedPropertyDescriptor<V>>, value: V): V;
export declare function __classPrivateFieldGet<T extends object, V>(receiver: T, privateMap: WeakMap<T, TypedPropertyDescriptor<V>>): V;
27 changes: 27 additions & 0 deletions tslib.es6.js
Original file line number Diff line number Diff line change
Expand Up @@ -196,3 +196,30 @@ export function __importStar(mod) {
export function __importDefault(mod) {
return (mod && mod.__esModule) ? mod : { default: mod };
}

export function __classPrivateFieldSet(receiver, privateMap, value) {
var descriptor = privateMap.get(receiver);
if (!descriptor) {
throw new TypeError("attempted to set private field on non-instance");
}
if (descriptor.set) {
descriptor.set.call(receiver, value);
} else {
if (!descriptor.writable) {
throw new TypeError("attempted to set read only private field");
}
descriptor.value = value;
}
return value;
}

export function __classPrivateFieldGet(receiver, privateMap) {
var descriptor = privateMap.get(receiver);
if (!descriptor) {
throw new TypeError("attempted to get private field on non-instance");
}
if (descriptor.get) {
return descriptor.get.call(receiver);
}
return descriptor.value;
}
31 changes: 31 additions & 0 deletions tslib.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ var __asyncValues;
var __makeTemplateObject;
var __importStar;
var __importDefault;
var __classPrivateFieldSet;
var __classPrivateFieldGet;
(function (factory) {
var root = typeof global === "object" ? global : typeof self === "object" ? self : typeof this === "object" ? this : {};
if (typeof define === "function" && define.amd) {
Expand Down Expand Up @@ -234,6 +236,33 @@ var __importDefault;
return (mod && mod.__esModule) ? mod : { "default": mod };
};

__classPrivateFieldSet = function (receiver, privateMap, value) {
var descriptor = privateMap.get(receiver);
if (!descriptor) {
throw new TypeError("attempted to set private field on non-instance");
}
if (descriptor.set) {
descriptor.set.call(receiver, value);
} else {
if (!descriptor.writable) {
throw new TypeError("attempted to set read only private field");
}
descriptor.value = value;
}
return value;
};

__classPrivateFieldGet = function (receiver, privateMap) {
var descriptor = privateMap.get(receiver);
if (!descriptor) {
throw new TypeError("attempted to get private field on non-instance");
}
if (descriptor.get) {
return descriptor.get.call(receiver);
}
return descriptor.value;
};

exporter("__extends", __extends);
exporter("__assign", __assign);
exporter("__rest", __rest);
Expand All @@ -254,4 +283,6 @@ var __importDefault;
exporter("__makeTemplateObject", __makeTemplateObject);
exporter("__importStar", __importStar);
exporter("__importDefault", __importDefault);
exporter("__classPrivateFieldSet", __classPrivateFieldSet);
exporter("__classPrivateFieldGet", __classPrivateFieldGet);
});