@nu-art/ts-common 0.33.21 → 0.33.25
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/core/application.js +2 -0
- package/core/application.js.map +1 -1
- package/core/debug-flags.js +2 -2
- package/core/debug-flags.js.map +1 -1
- package/core/dispatcher.d.ts +5 -3
- package/core/dispatcher.js +6 -5
- package/core/dispatcher.js.map +1 -1
- package/core/error-handling.d.ts +1 -1
- package/core/exceptions.js +2 -0
- package/core/exceptions.js.map +1 -1
- package/core/logger/BeLogged.js +1 -1
- package/core/logger/BeLogged.js.map +1 -1
- package/core/logger/LogClient.js +2 -2
- package/core/logger/LogClient.js.map +1 -1
- package/core/logger/LogClient_BaseRotate.js +3 -1
- package/core/logger/LogClient_BaseRotate.js.map +1 -1
- package/core/logger/LogClient_Browser.js +3 -1
- package/core/logger/LogClient_Browser.js.map +1 -1
- package/core/logger/LogClient_Function.js +7 -5
- package/core/logger/LogClient_Function.js.map +1 -1
- package/core/logger/LogClient_MemBuffer.js +2 -0
- package/core/logger/LogClient_MemBuffer.js.map +1 -1
- package/core/logger/LogClient_Terminal.js +4 -2
- package/core/logger/LogClient_Terminal.js.map +1 -1
- package/core/logger/utils.js +8 -8
- package/core/logger/utils.js.map +1 -1
- package/core/module-manager.js +5 -3
- package/core/module-manager.js.map +1 -1
- package/core/module.js +10 -8
- package/core/module.js.map +1 -1
- package/modules/CSVModule.js +3 -1
- package/modules/CSVModule.js.map +1 -1
- package/modules/CliParamsModule.js +7 -5
- package/modules/CliParamsModule.js.map +1 -1
- package/package.json +4 -11
- package/permissions/permission-group.js +2 -2
- package/permissions/permission-group.js.map +1 -1
- package/testing/test-model.js +6 -6
- package/testing/test-model.js.map +1 -1
- package/utils/array-tools.js +1 -2
- package/utils/array-tools.js.map +1 -1
- package/utils/crypto-tools.js +1 -1
- package/utils/crypto-tools.js.map +1 -1
- package/utils/date-time-tools.js +10 -8
- package/utils/date-time-tools.js.map +1 -1
- package/utils/filter-tools.js +1 -1
- package/utils/filter-tools.js.map +1 -1
- package/utils/merge-tools.js +4 -4
- package/utils/merge-tools.js.map +1 -1
- package/utils/object-tools.d.ts +4 -3
- package/utils/object-tools.js +1 -1
- package/utils/object-tools.js.map +1 -1
- package/utils/queue.js +4 -2
- package/utils/queue.js.map +1 -1
- package/utils/random-tools.js +1 -1
- package/utils/random-tools.js.map +1 -1
- package/utils/tools.js +3 -3
- package/utils/tools.js.map +1 -1
- package/utils/types.d.ts +5 -5
- package/validator/validator.d.ts +1 -1
- package/validator/validator.js +22 -20
- package/validator/validator.js.map +1 -1
- package/ts-generics/array-params.d.ts +0 -17
- package/ts-generics/array-params.js +0 -52
- package/ts-generics/array-params.js.map +0 -1
- package/ts-generics/omit-and-join.d.ts +0 -12
- package/ts-generics/omit-and-join.js +0 -46
- package/ts-generics/omit-and-join.js.map +0 -1
package/validator/validator.js
CHANGED
|
@@ -24,6 +24,8 @@ var __extends = (this && this.__extends) || (function () {
|
|
|
24
24
|
return extendStatics(d, b);
|
|
25
25
|
};
|
|
26
26
|
return function (d, b) {
|
|
27
|
+
if (typeof b !== "function" && b !== null)
|
|
28
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
27
29
|
extendStatics(d, b);
|
|
28
30
|
function __() { this.constructor = d; }
|
|
29
31
|
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
@@ -50,7 +52,7 @@ var assertMandatory = function (mandatory, path, input) {
|
|
|
50
52
|
if (input !== undefined && input !== null)
|
|
51
53
|
return;
|
|
52
54
|
if (mandatory)
|
|
53
|
-
throw new ValidationException("Missing mandatory field: "
|
|
55
|
+
throw new ValidationException("Missing mandatory field: ".concat(path, "\n"), path, input);
|
|
54
56
|
};
|
|
55
57
|
var tsValidateExists = function (mandatory) {
|
|
56
58
|
if (mandatory === void 0) { mandatory = true; }
|
|
@@ -65,16 +67,16 @@ var tsValidateObjectValues = function (validator, mandatory) {
|
|
|
65
67
|
assertMandatory(mandatory, path, input);
|
|
66
68
|
if (!input)
|
|
67
69
|
return;
|
|
68
|
-
for (var _i = 0, _a = object_tools_1._keys(input); _i < _a.length; _i++) {
|
|
70
|
+
for (var _i = 0, _a = (0, object_tools_1._keys)(input); _i < _a.length; _i++) {
|
|
69
71
|
var key = _a[_i];
|
|
70
72
|
var inputValue = input[key];
|
|
71
73
|
if (typeof inputValue === "object") {
|
|
72
|
-
var objectValidator = exports.tsValidateObjectValues(validator, mandatory);
|
|
74
|
+
var objectValidator = (0, exports.tsValidateObjectValues)(validator, mandatory);
|
|
73
75
|
if (!objectValidator)
|
|
74
76
|
return;
|
|
75
|
-
return objectValidator(path
|
|
77
|
+
return objectValidator("".concat(path, "/").concat(key), inputValue);
|
|
76
78
|
}
|
|
77
|
-
exports.tsValidate(inputValue, validator, path
|
|
79
|
+
(0, exports.tsValidate)(inputValue, validator, "".concat(path, "/").concat(key));
|
|
78
80
|
}
|
|
79
81
|
};
|
|
80
82
|
};
|
|
@@ -87,7 +89,7 @@ var tsValidateArray = function (validator, mandatory) {
|
|
|
87
89
|
return;
|
|
88
90
|
var _input = input;
|
|
89
91
|
for (var i = 0; i < _input.length; i++) {
|
|
90
|
-
exports.tsValidate(_input[i], validator, path
|
|
92
|
+
(0, exports.tsValidate)(_input[i], validator, "".concat(path, "/").concat(i));
|
|
91
93
|
}
|
|
92
94
|
};
|
|
93
95
|
};
|
|
@@ -100,7 +102,7 @@ var tsValidateRegexp = function (regexp, mandatory) {
|
|
|
100
102
|
return;
|
|
101
103
|
if (regexp.test(input))
|
|
102
104
|
return;
|
|
103
|
-
throw new ValidationException("Input does not match regexp for path("
|
|
105
|
+
throw new ValidationException("Input does not match regexp for path(".concat(path, "):\n input: ").concat(input, "\n regexp: ").concat(regexp, "\n"), path, input);
|
|
104
106
|
};
|
|
105
107
|
};
|
|
106
108
|
exports.tsValidateRegexp = tsValidateRegexp;
|
|
@@ -113,7 +115,7 @@ var tsValidateNumber = function (mandatory) {
|
|
|
113
115
|
// noinspection SuspiciousTypeOfGuard
|
|
114
116
|
if (typeof input === "number")
|
|
115
117
|
return;
|
|
116
|
-
throw new ValidationException("Input is not a number for path("
|
|
118
|
+
throw new ValidationException("Input is not a number for path(".concat(path, ")! \nvalue: ").concat(input, "\ntype: ").concat(typeof input), path, input);
|
|
117
119
|
};
|
|
118
120
|
};
|
|
119
121
|
exports.tsValidateNumber = tsValidateNumber;
|
|
@@ -126,7 +128,7 @@ var tsValidateBoolean = function (mandatory) {
|
|
|
126
128
|
// noinspection SuspiciousTypeOfGuard
|
|
127
129
|
if (typeof input === "boolean")
|
|
128
130
|
return;
|
|
129
|
-
throw new ValidationException("input is not a boolean! \nvalue: "
|
|
131
|
+
throw new ValidationException("input is not a boolean! \nvalue: ".concat(input, "\ntype: ").concat(typeof input), path, input);
|
|
130
132
|
};
|
|
131
133
|
};
|
|
132
134
|
exports.tsValidateBoolean = tsValidateBoolean;
|
|
@@ -138,7 +140,7 @@ var tsValidateValue = function (values, mandatory) {
|
|
|
138
140
|
return;
|
|
139
141
|
if (values.includes(input))
|
|
140
142
|
return;
|
|
141
|
-
throw new ValidationException("Input is not valid:\n input: "
|
|
143
|
+
throw new ValidationException("Input is not valid:\n input: ".concat(input, "\n options: ").concat((0, tools_1.__stringify)(values), "\n"), path, input);
|
|
142
144
|
};
|
|
143
145
|
};
|
|
144
146
|
exports.tsValidateValue = tsValidateValue;
|
|
@@ -153,7 +155,7 @@ var tsValidateRange = function (ranges, mandatory) {
|
|
|
153
155
|
if (range[0] <= input && input <= range[1])
|
|
154
156
|
return;
|
|
155
157
|
}
|
|
156
|
-
throw new ValidationException("Input is not valid:\n input: "
|
|
158
|
+
throw new ValidationException("Input is not valid:\n input: ".concat(input, "\n Expected Range: ").concat((0, tools_1.__stringify)(ranges), "\n"), path, input);
|
|
157
159
|
};
|
|
158
160
|
};
|
|
159
161
|
exports.tsValidateRange = tsValidateRange;
|
|
@@ -166,31 +168,31 @@ var tsValidate = function (instance, _validator, path, mandatory) {
|
|
|
166
168
|
var validator = _validator;
|
|
167
169
|
if (!validator)
|
|
168
170
|
return;
|
|
169
|
-
return validator(""
|
|
171
|
+
return validator("".concat(path), instance);
|
|
170
172
|
}
|
|
171
173
|
if (typeof _validator === "object") {
|
|
172
174
|
if (!instance && _validator)
|
|
173
|
-
throw new exceptions_1.BadImplementationException("Unexpect object at '"
|
|
175
|
+
throw new exceptions_1.BadImplementationException("Unexpect object at '".concat(path, "'\nif you want to ignore the validation of this object,\n add the following to your validator:\n {\n ...\n ").concat(path, ": undefined\n ...\n}\n"));
|
|
174
176
|
var __validator = _validator;
|
|
175
|
-
exports.tsValidateObject(__validator, instance, path);
|
|
177
|
+
(0, exports.tsValidateObject)(__validator, instance, path);
|
|
176
178
|
}
|
|
177
179
|
};
|
|
178
180
|
exports.tsValidate = tsValidate;
|
|
179
181
|
var tsValidateObject = function (__validator, instance, path) {
|
|
180
182
|
if (path === void 0) { path = ""; }
|
|
181
|
-
var validatorKeys = object_tools_1._keys(__validator);
|
|
183
|
+
var validatorKeys = (0, object_tools_1._keys)(__validator);
|
|
182
184
|
var instanceKeys = Object.keys(instance);
|
|
183
185
|
for (var _i = 0, instanceKeys_1 = instanceKeys; _i < instanceKeys_1.length; _i++) {
|
|
184
186
|
var key = instanceKeys_1[_i];
|
|
185
187
|
// @ts-ignore
|
|
186
188
|
if (!validatorKeys.includes(key))
|
|
187
|
-
throw new exceptions_1.BadImplementationException("Unexpect key '"
|
|
189
|
+
throw new exceptions_1.BadImplementationException("Unexpect key '".concat(path).concat(key, "'\nif you want to ignore the validation of this property,\n add the following to your validator:\n {\n ...\n ").concat(key, ": undefined\n ...\n}\n"));
|
|
188
190
|
}
|
|
189
191
|
for (var _a = 0, validatorKeys_1 = validatorKeys; _a < validatorKeys_1.length; _a++) {
|
|
190
192
|
var key = validatorKeys_1[_a];
|
|
191
193
|
var value = instance[key];
|
|
192
194
|
var validator = __validator[key];
|
|
193
|
-
exports.tsValidate(value, validator, path
|
|
195
|
+
(0, exports.tsValidate)(value, validator, "".concat(path, "/").concat(key));
|
|
194
196
|
}
|
|
195
197
|
};
|
|
196
198
|
exports.tsValidateObject = tsValidateObject;
|
|
@@ -200,17 +202,17 @@ var tsValidateTimestamp = function (interval, mandatory) {
|
|
|
200
202
|
assertMandatory(mandatory, path, input);
|
|
201
203
|
if (!input)
|
|
202
204
|
return;
|
|
203
|
-
var now = __1.currentTimeMillis();
|
|
205
|
+
var now = (0, __1.currentTimeMillis)();
|
|
204
206
|
var minTimestamp = now - (interval || now);
|
|
205
207
|
if (minTimestamp <= input && input <= now)
|
|
206
208
|
return;
|
|
207
|
-
throw new ValidationException("Input is not valid:\n input: "
|
|
209
|
+
throw new ValidationException("Input is not valid:\n input: ".concat(input, "\n Expected Interval: ").concat(minTimestamp, " - ").concat(now, "\n"), path, input);
|
|
208
210
|
};
|
|
209
211
|
};
|
|
210
212
|
exports.tsValidateTimestamp = tsValidateTimestamp;
|
|
211
213
|
var tsValidateAudit = function (range) { return function (_path, audit) {
|
|
212
214
|
var _a, _b;
|
|
213
|
-
(_a = exports.tsValidateRange([[0, Number.MAX_VALUE]], true)) === null || _a === void 0 ? void 0 : _a(_path, (_b = audit === null || audit === void 0 ? void 0 : audit.auditAt) === null || _b === void 0 ? void 0 : _b.timestamp);
|
|
215
|
+
(_a = (0, exports.tsValidateRange)([[0, Number.MAX_VALUE]], true)) === null || _a === void 0 ? void 0 : _a(_path, (_b = audit === null || audit === void 0 ? void 0 : audit.auditAt) === null || _b === void 0 ? void 0 : _b.timestamp);
|
|
214
216
|
}; };
|
|
215
217
|
exports.tsValidateAudit = tsValidateAudit;
|
|
216
218
|
//# sourceMappingURL=validator.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validator.js","sourceRoot":"","sources":["../../src/main/validator/validator.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;GAgBG
|
|
1
|
+
{"version":3,"file":"validator.js","sourceRoot":"","sources":["../../src/main/valid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gB;IACtE,OAAO,UAAC,IAAY,EAAE,KAAc;QACnC,eAAe,CAAC,SAAS,EAAE,IAAI,EAAE,KAAK,CAAC,CAAC;QACxC,IAAI,CAAC,KAAK;YACT,OAAO;QAER,IAAM,GAAG,GAAG,IAAA,qBAAiB,GAAE,CAAC;QAChC,IAAM,YAAY,GAAG,GAAG,GAAG,CAAC,QAAQ,IAAI,GAAG,CAAC,CAAC;QAC7C,IAAI,YAAY,IAAI,KAAK,IAAI,KAAK,IAAI,GAAG;YACxC,OAAO;QAER,MAAM,IAAI,mBAAmB,CAAC,wCAAiC,KAAK,oCAA0B,YAAY,gBAAM,GAAG,OAAI,EAAE,IAAI,EAAE,KAAK,CAAC,CAAC;IACvI,CAAC,CAAC;AACH,CAAC,CAAC;AAbW,QAAA,mBAAmB,uBAa9B;AAEK,IAAM,eAAe,GAAG,UAAC,KAAsB,IAAK,OAAA,UAAC,KAAa,EAAE,KAAe;;IACzF,MAAA,IAAA,uBAAe,EAAC,CAAC,CAAC,CAAC,EAAE,MAAM,CAAC,SAAS,CAAC,CAAC,EAAE,IAAI,CAAC,0CAAG,KAAK,EAAE,MAAA,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,OAAO,0CAAE,SAAS,CAAC,CAAC;AACpF,CAAC,EAF0D,CAE1D,CAAC;AAFW,QAAA,eAAe,mBAE1B"}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
declare type FunctionKeys<T> = {
|
|
2
|
-
[K in keyof T]: T[K] extends Function ? K : never;
|
|
3
|
-
}[keyof T];
|
|
4
|
-
declare class Dispatcher<T extends object, K extends FunctionKeys<T>, P = Parameters<T[K]>> {
|
|
5
|
-
protected readonly method: K;
|
|
6
|
-
constructor(method: K);
|
|
7
|
-
call1(obj: T, ...p: [P]): void;
|
|
8
|
-
call2(obj: T, p: P): void;
|
|
9
|
-
}
|
|
10
|
-
interface TestInterface {
|
|
11
|
-
methodToCall: (str: string, num: number) => void;
|
|
12
|
-
}
|
|
13
|
-
declare class TestClass implements TestInterface {
|
|
14
|
-
methodToCall(str: string, num: number): void;
|
|
15
|
-
}
|
|
16
|
-
declare const instance: TestClass;
|
|
17
|
-
declare const dispatcher: Dispatcher<TestInterface, "methodToCall", [str: string, num: number]>;
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/*
|
|
3
|
-
* ts-common is the basic building blocks of our typescript projects
|
|
4
|
-
*
|
|
5
|
-
* Copyright (C) 2020 Adam van der Kruk aka TacB0sS
|
|
6
|
-
*
|
|
7
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
8
|
-
* you may not use this file except in compliance with the License.
|
|
9
|
-
* You may obtain a copy of the License at
|
|
10
|
-
*
|
|
11
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
12
|
-
*
|
|
13
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
14
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
15
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
16
|
-
* See the License for the specific language governing permissions and
|
|
17
|
-
* limitations under the License.
|
|
18
|
-
*/
|
|
19
|
-
var Dispatcher = /** @class */ (function () {
|
|
20
|
-
function Dispatcher(method) {
|
|
21
|
-
this.method = method;
|
|
22
|
-
}
|
|
23
|
-
Dispatcher.prototype.call1 = function (obj) {
|
|
24
|
-
var p = [];
|
|
25
|
-
for (var _i = 1; _i < arguments.length; _i++) {
|
|
26
|
-
p[_i - 1] = arguments[_i];
|
|
27
|
-
}
|
|
28
|
-
// here it passes the first argument as an array with disregard to the types
|
|
29
|
-
(obj[this.method])(p);
|
|
30
|
-
};
|
|
31
|
-
Dispatcher.prototype.call2 = function (obj, p) {
|
|
32
|
-
// here compilation error: type 'P' is not an array
|
|
33
|
-
// but if I ts ignore, it passes as expected
|
|
34
|
-
obj[this.method].apply(obj, [p]);
|
|
35
|
-
};
|
|
36
|
-
return Dispatcher;
|
|
37
|
-
}());
|
|
38
|
-
var TestClass = /** @class */ (function () {
|
|
39
|
-
function TestClass() {
|
|
40
|
-
}
|
|
41
|
-
TestClass.prototype.methodToCall = function (str, num) {
|
|
42
|
-
console.log({ str: str, num: num });
|
|
43
|
-
};
|
|
44
|
-
;
|
|
45
|
-
return TestClass;
|
|
46
|
-
}());
|
|
47
|
-
var instance = new TestClass();
|
|
48
|
-
var dispatcher = new Dispatcher("methodToCall");
|
|
49
|
-
dispatcher.call1(instance, ["string", 42]);
|
|
50
|
-
// dispatcher.call1(instance, "string", 42);
|
|
51
|
-
// dispatcher.call2(instance, "string", 42);
|
|
52
|
-
//# sourceMappingURL=array-params.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"array-params.js","sourceRoot":"","sources":["../../src/main/ts-generics/array-params.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;GAgBG;AAIH;IAIC,oBAAY,MAAS;QACpB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACtB,CAAC;IAEM,0BAAK,GAAZ,UAAa,GAAM;QAAE,WAAS;aAAT,UAAS,EAAT,qBAAS,EAAT,IAAS;YAAT,0BAAS;;QAC7B,4EAA4E;QAC5E,CAAC,GAAG,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IACvB,CAAC;IAEM,0BAAK,GAAZ,UAAa,GAAM,EAAE,CAAI;QACxB,oDAAoD;QACpD,4CAA4C;QAC3C,GAAG,CAAC,IAAI,CAAC,MAAM,CAAC,OAAhB,GAAG,EAAkB,CAAC,CAAC,CAAC,EAAE;IAC5B,CAAC;IACF,iBAAC;AAAD,CAAC,AAlBD,IAkBC;AAOD;IAAA;IAMA,CAAC;IAHA,gCAAY,GAAZ,UAAa,GAAW,EAAE,GAAW;QACpC,OAAO,CAAC,GAAG,CAAC,EAAC,GAAG,KAAA,EAAE,GAAG,KAAA,EAAC,CAAC,CAAC;IACzB,CAAC;IAAA,CAAC;IACH,gBAAC;AAAD,CAAC,AAND,IAMC;AAGD,IAAM,QAAQ,GAAG,IAAI,SAAS,EAAE,CAAC;AAEjC,IAAM,UAAU,GAAG,IAAI,UAAU,CAAgC,cAAc,CAAC,CAAC;AAEjF,UAAU,CAAC,KAAK,CAAC,QAAQ,EAAE,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC,CAAC;AAC3C,4CAA4C;AAC5C,4CAA4C"}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
declare type A = {
|
|
2
|
-
_id: string;
|
|
3
|
-
};
|
|
4
|
-
declare type B = A & {
|
|
5
|
-
one: string;
|
|
6
|
-
two: string;
|
|
7
|
-
};
|
|
8
|
-
declare type C = Omit<B, "_id">;
|
|
9
|
-
declare const valueWithoutId: C;
|
|
10
|
-
declare const valueWithId: B;
|
|
11
|
-
declare function thisBreaks_butWhy<T extends A, U = Omit<T, "_id">>(_valueWithoutId: U): void;
|
|
12
|
-
declare function thisBreaksTOO_butWhy<T extends A>(_valueWithoutId: Omit<T, "_id">): void;
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/*
|
|
3
|
-
* ts-common is the basic building blocks of our typescript projects
|
|
4
|
-
*
|
|
5
|
-
* Copyright (C) 2020 Adam van der Kruk aka TacB0sS
|
|
6
|
-
*
|
|
7
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
8
|
-
* you may not use this file except in compliance with the License.
|
|
9
|
-
* You may obtain a copy of the License at
|
|
10
|
-
*
|
|
11
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
12
|
-
*
|
|
13
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
14
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
15
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
16
|
-
* See the License for the specific language governing permissions and
|
|
17
|
-
* limitations under the License.
|
|
18
|
-
*/
|
|
19
|
-
var __assign = (this && this.__assign) || function () {
|
|
20
|
-
__assign = Object.assign || function(t) {
|
|
21
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
22
|
-
s = arguments[i];
|
|
23
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
24
|
-
t[p] = s[p];
|
|
25
|
-
}
|
|
26
|
-
return t;
|
|
27
|
-
};
|
|
28
|
-
return __assign.apply(this, arguments);
|
|
29
|
-
};
|
|
30
|
-
var valueWithoutId = { one: "value-1", two: "value-2" };
|
|
31
|
-
// This works just fine...
|
|
32
|
-
var valueWithId = __assign(__assign({}, valueWithoutId), { _id: "new-id" });
|
|
33
|
-
console.log(valueWithId);
|
|
34
|
-
function thisBreaks_butWhy(_valueWithoutId) {
|
|
35
|
-
// The following line breaks... Why?
|
|
36
|
-
// @ts-ignore
|
|
37
|
-
var _valueWithId = __assign(__assign({}, _valueWithoutId), { _id: "new-id" });
|
|
38
|
-
}
|
|
39
|
-
function thisBreaksTOO_butWhy(_valueWithoutId) {
|
|
40
|
-
// The following line breaks... Why?
|
|
41
|
-
// @ts-ignore
|
|
42
|
-
var _valueWithId = __assign(__assign({}, _valueWithoutId), { _id: "new-id" });
|
|
43
|
-
}
|
|
44
|
-
// @ts-ignore
|
|
45
|
-
thisBreaks_butWhy({ one: "other-1", two: "other-2", three: "asdasd" });
|
|
46
|
-
//# sourceMappingURL=omit-and-join.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"omit-and-join.js","sourceRoot":"","sources":["../../src/main/ts-generics/omit-and-join.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;GAgBG;;;;;;;;;;;;AAQH,IAAM,cAAc,GAAM,EAAC,GAAG,EAAE,SAAS,EAAE,GAAG,EAAE,SAAS,EAAC,CAAC;AAE3D,0BAA0B;AAC1B,IAAM,WAAW,yBAAU,cAAc,KAAE,GAAG,EAAE,QAAQ,GAAC,CAAC;AAE1D,OAAO,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC;AAGzB,SAAS,iBAAiB,CAAkC,eAAkB;IAE7E,oCAAoC;IACpC,aAAa;IACb,IAAM,YAAY,yBAAU,eAAe,KAAE,GAAG,EAAE,QAAQ,GAAC,CAAC;AAC7D,CAAC;AAED,SAAS,oBAAoB,CAAc,eAA+B;IAEzE,oCAAoC;IACpC,aAAa;IACb,IAAM,YAAY,yBAAU,eAAe,KAAE,GAAG,EAAE,QAAQ,GAAC,CAAC;AAC7D,CAAC;AAED,aAAa;AACb,iBAAiB,CAAI,EAAC,GAAG,EAAE,SAAS,EAAE,GAAG,EAAE,SAAS,EAAE,KAAK,EAAE,QAAQ,EAAC,CAAC,CAAA"}
|