mirror of
https://gitlab.com/openstapps/openstapps.git
synced 2026-01-21 00:52:55 +00:00
fix: build
This commit is contained in:
@@ -15,7 +15,6 @@
|
||||
*/
|
||||
import equal = require('fast-deep-equal/es6');
|
||||
import clone = require('rfdc');
|
||||
import {Defined, TSOCType} from 'ts-optchain';
|
||||
import {SCLanguageCode} from './general/i18n';
|
||||
import {isThing} from './guards';
|
||||
import {SCClasses} from './meta';
|
||||
@@ -90,21 +89,15 @@ export class SCThingTranslator {
|
||||
* Get field value translation recursively
|
||||
*
|
||||
* @param data The intermediate object / primitive returned by the Proxys get() method
|
||||
* @returns an TSOCType<T> object allowing for access to translations or a translated value(s)
|
||||
* @returns a T object allowing for access to translations or a translated value(s)
|
||||
*/
|
||||
private deeptranslate<T>(data?: T): TSOCType<T> {
|
||||
const proxy = new Proxy(
|
||||
((defaultValue?: Defined<T>) => (data == undefined ? defaultValue : data)) as TSOCType<T>,
|
||||
private deeptranslate<T>(data: T): T {
|
||||
return typeof data === 'object' ? new Proxy(
|
||||
data as never,
|
||||
{
|
||||
get: (target, key) => {
|
||||
const object: any = target();
|
||||
|
||||
return this.deeptranslate(object[key]);
|
||||
},
|
||||
get: (target, key) => this.deeptranslate(target[key as never]),
|
||||
},
|
||||
);
|
||||
|
||||
return proxy;
|
||||
) as unknown as T : data;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -260,12 +253,12 @@ export class SCThingTranslator {
|
||||
* @param thing Top level object that gets passed through the recursion
|
||||
* @returns an TSOCType<T> object allowing for access to translations or a translated value(s)
|
||||
*/
|
||||
public translatedAccess<T extends SCThing>(thing: T): TSOCType<T> {
|
||||
public translatedAccess<T extends SCThing>(thing: T): T {
|
||||
return new Proxy(
|
||||
((defaultValue?: Defined<T>) => (thing == undefined ? defaultValue : thing)) as TSOCType<T>,
|
||||
thing,
|
||||
{
|
||||
get: (target, key) => {
|
||||
const object: any = target();
|
||||
const object: any = target;
|
||||
if (equal(this.sourceCache.get(thing), thing)) {
|
||||
const objectTranslatedFromCache = this.cache.get(thing);
|
||||
if (objectTranslatedFromCache !== undefined) {
|
||||
|
||||
Reference in New Issue
Block a user