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

update private class element helpers #146

Merged
merged 1 commit into from
Mar 25, 2021
Merged
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
94 changes: 92 additions & 2 deletions tslib.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,96 @@ 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 __classPrivateFieldGet<T extends object, V>(receiver: T, privateMap: { has(o: T): boolean, get(o: T): V | undefined }): V;
export declare function __classPrivateFieldSet<T extends object, V>(receiver: T, privateMap: { has(o: T): boolean, set(o: T, value: V): any }, value: V): V;
/**
* Reading from a private instance field
*/
export declare function __classPrivateFieldGet<T extends object, V>(
receiver: T,
state: { has(o: T): boolean, get(o: T): V | undefined },
kind?: "f"
): V;
/**
* Reading from a private static field
*/
export declare function __classPrivateFieldGet<T extends new (...args: any[]) => unknown, V>(
receiver: T,
state: T,
kind: "f",
f: { value: V }
): V;
/**
* Reading from a private instance get accessor
*/
export declare function __classPrivateFieldGet<T extends object, V>(
receiver: T,
state: { has(o: T): boolean },
kind: "a",
f: () => V
): V;
/**
* Reading from a private static get accessor
*/
export declare function __classPrivateFieldGet<T extends new (...args: any[]) => unknown, V>(
receiver: T,
state: T,
kind: "a",
f: () => V
): V;
/**
* Reading from a private instance method
*/
export declare function __classPrivateFieldGet<T extends object, V extends (...args: any[]) => unknown>(
receiver: T,
state: { has(o: T): boolean },
kind: "m",
f: V
): V;
/**
* Reading from a private static method
*/
export declare function __classPrivateFieldGet<T extends new (...args: any[]) => unknown, V extends (...args: any[]) => unknown>(
receiver: T,
state: T,
kind: "m",
f: V
): V;
/**
* Writing to a private instance field
*/
export declare function __classPrivateFieldSet<T extends object, V>(
receiver: T,
state: { has(o: T): boolean, set(o: T, value: V): unknown },
value: V,
kind?: "f"
): V;
/**
* Writing to a private static field
*/
export declare function __classPrivateFieldSet<T extends new (...args: any[]) => unknown, V>(
receiver: T,
state: T,
value: V,
kind: "f",
f: { value: V }
): V;
/**
* Writing to a private instance set accessor
*/
export declare function __classPrivateFieldSet<T extends object, V>(
receiver: T,
state: { has(o: T): boolean },
value: V,
kind: "a",
f: (v: V) => void
): V;
/**
* Writing to a private static set accessor
*/
export declare function __classPrivateFieldSet<T extends new (...args: any[]) => unknown, V>(
receiver: T,
state: T,
value: V,
kind: "a",
f: (v: V) => void
): V;
export declare function __createBinding(object: object, target: object, key: PropertyKey, objectKey?: PropertyKey): void;
20 changes: 9 additions & 11 deletions tslib.es6.js
Original file line number Diff line number Diff line change
Expand Up @@ -221,17 +221,15 @@ export function __importDefault(mod) {
return (mod && mod.__esModule) ? mod : { default: mod };
}

export function __classPrivateFieldGet(receiver, privateMap) {
if (!privateMap.has(receiver)) {
throw new TypeError("attempted to get private field on non-instance");
}
return privateMap.get(receiver);
export function __classPrivateFieldGet(receiver, state, kind, f) {
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
}

export function __classPrivateFieldSet(receiver, privateMap, value) {
if (!privateMap.has(receiver)) {
throw new TypeError("attempted to set private field on non-instance");
}
privateMap.set(receiver, value);
return value;
export function __classPrivateFieldSet(receiver, state, value, kind, f) {
if (kind === "m") throw new TypeError("Private method is not writable");
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
}
20 changes: 9 additions & 11 deletions tslib.js
Original file line number Diff line number Diff line change
Expand Up @@ -262,19 +262,17 @@ var __createBinding;
return (mod && mod.__esModule) ? mod : { "default": mod };
};

__classPrivateFieldGet = function (receiver, privateMap) {
if (!privateMap.has(receiver)) {
throw new TypeError("attempted to get private field on non-instance");
}
return privateMap.get(receiver);
__classPrivateFieldGet = function (receiver, state, kind, f) {
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
};

__classPrivateFieldSet = function (receiver, privateMap, value) {
if (!privateMap.has(receiver)) {
throw new TypeError("attempted to set private field on non-instance");
}
privateMap.set(receiver, value);
return value;
__classPrivateFieldSet = function (receiver, state, value, kind, f) {
if (kind === "m") throw new TypeError("Private method is not writable");
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
};

exporter("__extends", __extends);
Expand Down