mnemonica 1.3.8 → 1.4.0
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/FOR_HUMANS.md +101 -31
- package/README.md +2 -2
- package/build/api/errors/index.d.ts +3 -7
- package/build/api/errors/index.js +3 -5
- package/build/api/errors/throwModificationError.js +2 -4
- package/build/api/hooks/HookInvocation.d.ts +2 -2
- package/build/api/hooks/HookInvocation.js +1 -1
- package/build/api/hooks/flowCheckers.d.ts +3 -3
- package/build/api/hooks/flowCheckers.js +1 -1
- package/build/api/index.d.ts +3 -3
- package/build/api/types/index.d.ts +3 -3
- package/build/api/types/index.js +18 -26
- package/build/api/utils/index.d.ts +2 -2
- package/build/api/utils/index.js +31 -18
- package/build/descriptors/errors/index.js +1 -1
- package/build/descriptors/types/index.js +8 -8
- package/build/index.d.ts +10 -13
- package/build/index.js +13 -16
- package/build/types/index.d.ts +89 -25
- package/build/types/index.js +1 -1
- package/build/utils/collectConstructors.js +1 -1
- package/build/utils/fork.d.ts +2 -1
- package/build/utils/fork.js +1 -1
- package/build/utils/index.js +10 -8
- package/build/utils/parse.js +5 -2
- package/docs/UTILS.md +3 -2
- package/docs/async-constructors.md +5 -3
- package/docs/empathy-in-ai.md +2 -2
- package/docs/prototype-chain.md +1 -1
- package/docs/typed-lookup.md +3 -1
- package/package.json +12 -12
- package/src/api/errors/index.ts +12 -15
- package/src/api/errors/throwModificationError.ts +3 -4
- package/src/api/hooks/HookInvocation.ts +6 -5
- package/src/api/hooks/flowCheckers.ts +6 -3
- package/src/api/types/index.ts +45 -44
- package/src/api/utils/index.ts +60 -24
- package/src/descriptors/errors/index.ts +4 -5
- package/src/descriptors/types/index.ts +20 -16
- package/src/index.ts +55 -47
- package/src/types/index.ts +252 -39
- package/src/utils/collectConstructors.ts +0 -9
- package/src/utils/fork.ts +2 -1
- package/src/utils/index.ts +15 -14
- package/src/utils/parse.ts +9 -1
package/src/api/errors/index.ts
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
import type {
|
|
3
|
+
import type {
|
|
4
|
+
StackBoundary,
|
|
5
|
+
MnemonicaErrorConstructor
|
|
6
|
+
} from '../../types';
|
|
4
7
|
|
|
5
8
|
import { constants } from '../../constants';
|
|
6
9
|
|
|
@@ -76,7 +79,7 @@ export const getStack = function (
|
|
|
76
79
|
|
|
77
80
|
export class BASE_MNEMONICA_ERROR extends Error {
|
|
78
81
|
|
|
79
|
-
constructor ( message = BASE_ERROR_MESSAGE, additionalStack
|
|
82
|
+
constructor ( message = BASE_ERROR_MESSAGE, additionalStack?: string[] ) {
|
|
80
83
|
|
|
81
84
|
super( message );
|
|
82
85
|
const BaseStack: string = this.stack as string;
|
|
@@ -119,9 +122,9 @@ Object.defineProperty(
|
|
|
119
122
|
);
|
|
120
123
|
|
|
121
124
|
|
|
122
|
-
export const constructError = ( name: string, message: string ) => {
|
|
125
|
+
export const constructError = ( name: string, message: string ): MnemonicaErrorConstructor => {
|
|
123
126
|
const NamedErrorConstructor = class extends BASE_MNEMONICA_ERROR {
|
|
124
|
-
constructor ( addition
|
|
127
|
+
constructor ( addition?: string, stack?: string[] ) {
|
|
125
128
|
const saying = addition ? `${message} : ${addition}` : `${message}`;
|
|
126
129
|
super(
|
|
127
130
|
saying,
|
|
@@ -130,23 +133,17 @@ export const constructError = ( name: string, message: string ) => {
|
|
|
130
133
|
}
|
|
131
134
|
};
|
|
132
135
|
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
prototype: {
|
|
136
|
-
constructor: CallableFunction
|
|
137
|
-
}
|
|
138
|
-
},
|
|
139
|
-
};
|
|
140
|
-
reNamer[ name ] = NamedErrorConstructor;
|
|
136
|
+
// the class's prototype.constructor IS the class, so the name getter is
|
|
137
|
+
// defined on the class itself (same effect as BASE_MNEMONICA_ERROR's above)
|
|
141
138
|
Object.defineProperty(
|
|
142
|
-
|
|
139
|
+
NamedErrorConstructor,
|
|
143
140
|
'name',
|
|
144
141
|
{
|
|
145
142
|
get () {
|
|
146
143
|
const result = new String( name );
|
|
147
144
|
return result;
|
|
148
145
|
}
|
|
149
|
-
}
|
|
146
|
+
}
|
|
150
147
|
);
|
|
151
|
-
return
|
|
148
|
+
return NamedErrorConstructor;
|
|
152
149
|
};
|
|
@@ -11,11 +11,10 @@ const {
|
|
|
11
11
|
} = constants;
|
|
12
12
|
|
|
13
13
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
14
|
+
// the base class itself (ErrorsTypes holds this same class): instanceof
|
|
15
|
+
// against it narrows to the class's own instance type
|
|
17
16
|
import {
|
|
18
|
-
cleanupStack, getStack
|
|
17
|
+
BASE_MNEMONICA_ERROR, cleanupStack, getStack
|
|
19
18
|
} from './';
|
|
20
19
|
|
|
21
20
|
import TypesUtils from '../utils';
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
import type {
|
|
4
|
-
|
|
4
|
+
ThrowModificationError,
|
|
5
|
+
deliveredHookOpts, TypeDef
|
|
5
6
|
} from '../../types';
|
|
6
7
|
|
|
7
|
-
//
|
|
8
|
+
// deliveredHookOpts is used in build() return type
|
|
8
9
|
|
|
9
10
|
/**
|
|
10
11
|
* Builder for hook invocation arguments.
|
|
@@ -21,7 +22,7 @@ export class HookInvocation {
|
|
|
21
22
|
private readonly existentInstance: object;
|
|
22
23
|
private readonly args: unknown[];
|
|
23
24
|
private inheritedInstance?: object;
|
|
24
|
-
private _throwModificationError?:
|
|
25
|
+
private _throwModificationError?: ThrowModificationError;
|
|
25
26
|
|
|
26
27
|
constructor (
|
|
27
28
|
type: TypeDef,
|
|
@@ -46,8 +47,8 @@ export class HookInvocation {
|
|
|
46
47
|
return this;
|
|
47
48
|
}
|
|
48
49
|
|
|
49
|
-
build ():
|
|
50
|
-
const result:
|
|
50
|
+
build (): deliveredHookOpts {
|
|
51
|
+
const result: deliveredHookOpts = {
|
|
51
52
|
type : this.type,
|
|
52
53
|
TypeName : this.TypeName,
|
|
53
54
|
existentInstance : this.existentInstance,
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
import type {
|
|
3
|
+
import type {
|
|
4
|
+
Hookable,
|
|
5
|
+
FlowChecker
|
|
6
|
+
} from '../../types';
|
|
4
7
|
|
|
5
8
|
import { ErrorsTypes } from '../../descriptors/errors';
|
|
6
9
|
const {
|
|
@@ -10,8 +13,8 @@ const {
|
|
|
10
13
|
|
|
11
14
|
// the stored checker receives the hook invocation record — same contract
|
|
12
15
|
// Hookable.registerFlowChecker declares for its callback
|
|
13
|
-
export const flowCheckers = new WeakMap<Hookable,
|
|
14
|
-
export const registerFlowChecker = function (this: Hookable, cb:
|
|
16
|
+
export const flowCheckers = new WeakMap<Hookable, FlowChecker>();
|
|
17
|
+
export const registerFlowChecker = function (this: Hookable, cb: FlowChecker ) {
|
|
15
18
|
|
|
16
19
|
if ( typeof cb !== 'function' ) {
|
|
17
20
|
throw new MISSING_CALLBACK_ARGUMENT;
|
package/src/api/types/index.ts
CHANGED
|
@@ -31,6 +31,9 @@ import {
|
|
|
31
31
|
TypeAbsorber,
|
|
32
32
|
ModificationConstructorFactory,
|
|
33
33
|
MnemonicaConstructorFactory,
|
|
34
|
+
DefineNewableOrCallable,
|
|
35
|
+
DefineNewable,
|
|
36
|
+
LazyDef,
|
|
34
37
|
} from '../../types';
|
|
35
38
|
|
|
36
39
|
// Lazy getter: a function that, when called, returns the actual constructor function.
|
|
@@ -213,8 +216,8 @@ Object.assign(
|
|
|
213
216
|
|
|
214
217
|
TypeDescriptor.prototype.define = function (
|
|
215
218
|
this: TypeDescriptorInstance,
|
|
216
|
-
TypeOrTypeName: string |
|
|
217
|
-
constructHandlerOrConfig?:
|
|
219
|
+
TypeOrTypeName: string | DefineNewableOrCallable,
|
|
220
|
+
constructHandlerOrConfig?: DefineNewableOrCallable | object,
|
|
218
221
|
config?: object
|
|
219
222
|
) {
|
|
220
223
|
const result = define.call(
|
|
@@ -229,20 +232,20 @@ TypeDescriptor.prototype.define = function (
|
|
|
229
232
|
|
|
230
233
|
TypeDescriptor.prototype.lazy = function (
|
|
231
234
|
this: TypeDescriptorInstance,
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
+
TypeNameOrGetter: string | LazyDef<object>,
|
|
236
|
+
getterOrConfig?: LazyDef<object> | object,
|
|
237
|
+
namedFormConfig?: object
|
|
235
238
|
) {
|
|
236
239
|
let name: string | undefined;
|
|
237
240
|
let getter: LazyTypeGetter;
|
|
238
241
|
let config: object | undefined;
|
|
239
|
-
if (typeof
|
|
240
|
-
name =
|
|
241
|
-
getter =
|
|
242
|
-
config =
|
|
242
|
+
if (typeof TypeNameOrGetter === 'string') {
|
|
243
|
+
name = TypeNameOrGetter;
|
|
244
|
+
getter = getterOrConfig as LazyTypeGetter;
|
|
245
|
+
config = namedFormConfig;
|
|
243
246
|
} else {
|
|
244
|
-
getter =
|
|
245
|
-
config =
|
|
247
|
+
getter = TypeNameOrGetter as LazyTypeGetter;
|
|
248
|
+
config = getterOrConfig as object;
|
|
246
249
|
}
|
|
247
250
|
let result: TypeClass;
|
|
248
251
|
if (name) {
|
|
@@ -297,7 +300,7 @@ odp(
|
|
|
297
300
|
get (this: TypeDescriptorInstance) {
|
|
298
301
|
const self = this;
|
|
299
302
|
const result = function (options?: object) {
|
|
300
|
-
const decorator = function (cstr:
|
|
303
|
+
const decorator = function (cstr: DefineNewable) {
|
|
301
304
|
const { name } = cstr;
|
|
302
305
|
// define() returns the registered constructor itself —
|
|
303
306
|
// the full TypeClass is a richer honest type than any cast
|
|
@@ -500,36 +503,34 @@ const createFromLazyGetter = function (
|
|
|
500
503
|
(typeof type.prototype === 'object')
|
|
501
504
|
) ? type.prototype : getDefaultPrototype();
|
|
502
505
|
|
|
506
|
+
// the getter's raw function cannot construct directly: it lacks the
|
|
507
|
+
// compiled modificator body — the type's name on prototype.constructor,
|
|
508
|
+
// the CreationHandler call, the Reflect.construct with new.target —
|
|
509
|
+
// which is why named lazy with an anonymous or differently named
|
|
510
|
+
// handler failed to construct, and async lazy handlers broke. Build
|
|
511
|
+
// through the SAME wrapper as the direct path, per construction: the
|
|
512
|
+
// getter may return a NEW function each time, so neither the shape
|
|
513
|
+
// check nor the wrapper can be cached. This is what makes lazy slower
|
|
514
|
+
// than a direct define
|
|
515
|
+
const modificatorBody = compileNewModificatorFunctionBody(
|
|
516
|
+
TypeName,
|
|
517
|
+
asClass
|
|
518
|
+
);
|
|
519
|
+
|
|
503
520
|
const makeConstructHandler = () => {
|
|
504
521
|
const constructHandler = getter();
|
|
505
522
|
|
|
506
|
-
// and on EVERY construction: the getter may return a new function
|
|
507
|
-
// each time, so the shape check cannot be cached from define time.
|
|
508
|
-
// This is what makes lazy slower than a direct define
|
|
509
523
|
classifyConstructHandler(
|
|
510
524
|
TypeName,
|
|
511
525
|
constructHandler as ConstructHandler
|
|
512
526
|
);
|
|
513
527
|
|
|
514
|
-
|
|
515
|
-
constructHandler,
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
return TypeName;
|
|
519
|
-
}
|
|
520
|
-
}
|
|
528
|
+
const wrappedBody = modificatorBody(
|
|
529
|
+
constructHandler as ConstructHandler,
|
|
530
|
+
CreationHandler,
|
|
531
|
+
SymbolConstructorName
|
|
521
532
|
);
|
|
522
|
-
|
|
523
|
-
const protoDesc = Object
|
|
524
|
-
.getOwnPropertyDescriptor(
|
|
525
|
-
constructHandler,
|
|
526
|
-
'prototype'
|
|
527
|
-
) as PropertyDescriptor | undefined;
|
|
528
|
-
if (protoDesc && protoDesc.writable) {
|
|
529
|
-
constructHandler.prototype = getDefaultPrototype();
|
|
530
|
-
}
|
|
531
|
-
|
|
532
|
-
const handlerResult = constructHandler as MnemonicaConstructorFactory;
|
|
533
|
+
const handlerResult = wrappedBody();
|
|
533
534
|
return handlerResult;
|
|
534
535
|
};
|
|
535
536
|
|
|
@@ -569,8 +570,8 @@ const createFromLazyGetter = function (
|
|
|
569
570
|
export const define = function (
|
|
570
571
|
this: unknown,
|
|
571
572
|
subtypes: TypesMap,
|
|
572
|
-
TypeOrTypeName: string |
|
|
573
|
-
constructHandlerOrConfig?:
|
|
573
|
+
TypeOrTypeName: string | DefineNewableOrCallable,
|
|
574
|
+
constructHandlerOrConfig?: DefineNewableOrCallable | object,
|
|
574
575
|
config?: object
|
|
575
576
|
): TypeClass {
|
|
576
577
|
|
|
@@ -638,21 +639,21 @@ export const define = function (
|
|
|
638
639
|
export const lazy = function (
|
|
639
640
|
this: unknown,
|
|
640
641
|
subtypes: TypesMap,
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
642
|
+
TypeNameOrGetter: string | LazyTypeGetter | undefined,
|
|
643
|
+
getterOrConfig?: LazyTypeGetter | object,
|
|
644
|
+
namedFormConfig?: object
|
|
644
645
|
): TypeClass {
|
|
645
646
|
|
|
646
647
|
let name: string | undefined;
|
|
647
648
|
let getter: LazyTypeGetter;
|
|
648
649
|
let config: object | undefined;
|
|
649
|
-
if (typeof
|
|
650
|
-
name =
|
|
651
|
-
getter =
|
|
652
|
-
config =
|
|
650
|
+
if (typeof TypeNameOrGetter === 'string') {
|
|
651
|
+
name = TypeNameOrGetter;
|
|
652
|
+
getter = getterOrConfig as LazyTypeGetter;
|
|
653
|
+
config = namedFormConfig;
|
|
653
654
|
} else {
|
|
654
|
-
getter =
|
|
655
|
-
config =
|
|
655
|
+
getter = TypeNameOrGetter as LazyTypeGetter;
|
|
656
|
+
config = getterOrConfig as object;
|
|
656
657
|
}
|
|
657
658
|
|
|
658
659
|
if (typeof getter !== 'function') {
|
package/src/api/utils/index.ts
CHANGED
|
@@ -16,13 +16,19 @@ const { WRONG_TYPE_DEFINITION, } = ErrorsTypes;
|
|
|
16
16
|
import {
|
|
17
17
|
_getProps, Props
|
|
18
18
|
} from '../types/Props';
|
|
19
|
-
import type {
|
|
19
|
+
import type {
|
|
20
|
+
InstanceConstructor,
|
|
21
|
+
MnemonicaConstructor
|
|
22
|
+
} from '../../types';
|
|
20
23
|
|
|
21
24
|
import compileNewModificatorFunctionBody, { ConstructHandler } from '../types/compileNewModificatorFunctionBody';
|
|
22
25
|
|
|
23
26
|
// CreationHandler - handles constructor return values
|
|
24
27
|
// Moved to api/types/index.ts as per refactoring plan
|
|
25
|
-
export const CreationHandler = function (
|
|
28
|
+
export const CreationHandler = function (
|
|
29
|
+
this: object & { constructor: InstanceConstructor },
|
|
30
|
+
constructionAnswer: unknown
|
|
31
|
+
) {
|
|
26
32
|
return constructionAnswer;
|
|
27
33
|
};
|
|
28
34
|
|
|
@@ -274,23 +280,59 @@ const makeErrorModificatorType = (
|
|
|
274
280
|
};
|
|
275
281
|
|
|
276
282
|
|
|
277
|
-
//
|
|
283
|
+
// a null or primitive-wrapper parent reflects its primitive to the instance
|
|
284
|
+
// built over it: coercion (+inst, `${inst}`) through Symbol.toPrimitive, and
|
|
285
|
+
// explicit inst.valueOf() / inst.toString() — the wrapper's own prototype
|
|
286
|
+
// methods throw when `this` is the instance rather than the wrapper, and an
|
|
287
|
+
// Object.create(null) parent has none at all
|
|
288
|
+
const reflectPrimitive = (thisArg: object, primitive: null | string | number | boolean) => {
|
|
289
|
+
odp(
|
|
290
|
+
thisArg,
|
|
291
|
+
Symbol.toPrimitive,
|
|
292
|
+
{
|
|
293
|
+
get () {
|
|
294
|
+
const result = () => {
|
|
295
|
+
return primitive;
|
|
296
|
+
};
|
|
297
|
+
return result;
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
);
|
|
301
|
+
odp(
|
|
302
|
+
thisArg,
|
|
303
|
+
'valueOf',
|
|
304
|
+
{
|
|
305
|
+
get () {
|
|
306
|
+
const result = () => {
|
|
307
|
+
return primitive;
|
|
308
|
+
};
|
|
309
|
+
return result;
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
);
|
|
313
|
+
odp(
|
|
314
|
+
thisArg,
|
|
315
|
+
'toString',
|
|
316
|
+
{
|
|
317
|
+
get () {
|
|
318
|
+
const result = () => {
|
|
319
|
+
const stringResult = String( primitive );
|
|
320
|
+
return stringResult;
|
|
321
|
+
};
|
|
322
|
+
return result;
|
|
323
|
+
}
|
|
324
|
+
}
|
|
325
|
+
);
|
|
326
|
+
};
|
|
327
|
+
|
|
278
328
|
const reflectPrimitiveWrappers = (_thisArg: unknown) => {
|
|
279
329
|
let thisArg: object = _thisArg as object;
|
|
280
330
|
|
|
281
331
|
if (_thisArg === null) {
|
|
282
332
|
thisArg = Object.create(null);
|
|
283
|
-
|
|
333
|
+
reflectPrimitive(
|
|
284
334
|
thisArg,
|
|
285
|
-
|
|
286
|
-
{
|
|
287
|
-
get () {
|
|
288
|
-
const result = () => {
|
|
289
|
-
return _thisArg;
|
|
290
|
-
};
|
|
291
|
-
return result;
|
|
292
|
-
}
|
|
293
|
-
}
|
|
335
|
+
null
|
|
294
336
|
);
|
|
295
337
|
}
|
|
296
338
|
|
|
@@ -299,18 +341,12 @@ const reflectPrimitiveWrappers = (_thisArg: unknown) => {
|
|
|
299
341
|
_thisArg instanceof Boolean ||
|
|
300
342
|
_thisArg instanceof String
|
|
301
343
|
) {
|
|
302
|
-
|
|
344
|
+
// read once, before the wrapper gets its own valueOf below;
|
|
345
|
+
// a wrapper's primitive never changes
|
|
346
|
+
const primitive = (_thisArg as String | Number | Boolean).valueOf();
|
|
347
|
+
reflectPrimitive(
|
|
303
348
|
thisArg,
|
|
304
|
-
|
|
305
|
-
{
|
|
306
|
-
get () {
|
|
307
|
-
const result = () => {
|
|
308
|
-
const valueResult = (_thisArg as String | Number | Boolean).valueOf();
|
|
309
|
-
return valueResult;
|
|
310
|
-
};
|
|
311
|
-
return result;
|
|
312
|
-
}
|
|
313
|
-
}
|
|
349
|
+
primitive
|
|
314
350
|
);
|
|
315
351
|
}
|
|
316
352
|
|
|
@@ -10,10 +10,9 @@ const { ErrorMessages, } = constants;
|
|
|
10
10
|
|
|
11
11
|
// ErrorsTypes is dynamically built - using MnemonicaErrorConstructor to indicate these are constructable
|
|
12
12
|
export const ErrorsTypes: { [ index: string ]: MnemonicaErrorConstructor } = {
|
|
13
|
-
//
|
|
14
|
-
//
|
|
15
|
-
|
|
16
|
-
BASE_MNEMONICA_ERROR : BASE_MNEMONICA_ERROR as unknown as MnemonicaErrorConstructor
|
|
13
|
+
// the base class takes the whole message (not an addition) as its
|
|
14
|
+
// first argument — it has no fixed message of its own
|
|
15
|
+
BASE_MNEMONICA_ERROR : BASE_MNEMONICA_ERROR
|
|
17
16
|
};
|
|
18
17
|
|
|
19
18
|
Object.entries( ErrorMessages ).forEach( entry => {
|
|
@@ -23,7 +22,7 @@ Object.entries( ErrorMessages ).forEach( entry => {
|
|
|
23
22
|
ErrorConstructorName,
|
|
24
23
|
message
|
|
25
24
|
);
|
|
26
|
-
ErrorsTypes[ ErrorConstructorName ] = ErrorCtor
|
|
25
|
+
ErrorsTypes[ ErrorConstructorName ] = ErrorCtor;
|
|
27
26
|
} );
|
|
28
27
|
|
|
29
28
|
|
|
@@ -7,7 +7,11 @@ import type {
|
|
|
7
7
|
TypeClass,
|
|
8
8
|
IDEF,
|
|
9
9
|
hooksOpts,
|
|
10
|
-
hook
|
|
10
|
+
hook,
|
|
11
|
+
StackBoundary,
|
|
12
|
+
DefineNewable,
|
|
13
|
+
DefineNewableOrCallable,
|
|
14
|
+
FlowChecker
|
|
11
15
|
} from '../../types';
|
|
12
16
|
|
|
13
17
|
import { constants } from '../../constants';
|
|
@@ -151,9 +155,9 @@ odp(
|
|
|
151
155
|
get (this: { subtypes: Map<string, object> }) {
|
|
152
156
|
const { subtypes } = this;
|
|
153
157
|
const result = function (
|
|
154
|
-
this:
|
|
155
|
-
TypeOrTypeName: string |
|
|
156
|
-
constructHandlerOrConfig?:
|
|
158
|
+
this: StackBoundary,
|
|
159
|
+
TypeOrTypeName: string | DefineNewableOrCallable,
|
|
160
|
+
constructHandlerOrConfig?: DefineNewableOrCallable | object,
|
|
157
161
|
config?: object
|
|
158
162
|
) {
|
|
159
163
|
// pass `result` itself as the stack-capture boundary (StackBoundary):
|
|
@@ -181,21 +185,21 @@ odp(
|
|
|
181
185
|
get (this: { subtypes: Map<string, object> }) {
|
|
182
186
|
const { subtypes } = this;
|
|
183
187
|
const result = function (
|
|
184
|
-
this:
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
+
this: StackBoundary,
|
|
189
|
+
TypeNameOrGetter: string | LazyTypeGetter,
|
|
190
|
+
getterOrConfig?: LazyTypeGetter | object,
|
|
191
|
+
namedFormConfig?: object
|
|
188
192
|
) {
|
|
189
193
|
let name: string | undefined;
|
|
190
194
|
let getter: LazyTypeGetter;
|
|
191
195
|
let config: object | undefined;
|
|
192
|
-
if (typeof
|
|
193
|
-
name =
|
|
194
|
-
getter =
|
|
195
|
-
config =
|
|
196
|
+
if (typeof TypeNameOrGetter === 'string') {
|
|
197
|
+
name = TypeNameOrGetter;
|
|
198
|
+
getter = getterOrConfig as LazyTypeGetter;
|
|
199
|
+
config = namedFormConfig;
|
|
196
200
|
} else {
|
|
197
|
-
getter =
|
|
198
|
-
config =
|
|
201
|
+
getter = TypeNameOrGetter as LazyTypeGetter;
|
|
202
|
+
config = getterOrConfig as object;
|
|
199
203
|
}
|
|
200
204
|
let lazyResult: TypeClass;
|
|
201
205
|
// same as in `define` above: pass `result` itself as the
|
|
@@ -231,7 +235,7 @@ odp(
|
|
|
231
235
|
get (this: TypesCollection) {
|
|
232
236
|
const self = this;
|
|
233
237
|
const result = function (config?: object) {
|
|
234
|
-
const decorator = function (cstr:
|
|
238
|
+
const decorator = function (cstr: DefineNewable) {
|
|
235
239
|
const { name } = cstr;
|
|
236
240
|
const defineResult = self.define(
|
|
237
241
|
name,
|
|
@@ -317,7 +321,7 @@ odp(
|
|
|
317
321
|
'registerFlowChecker',
|
|
318
322
|
{
|
|
319
323
|
get (this: TypesCollection) {
|
|
320
|
-
const result = (flowCheckerCallback:
|
|
324
|
+
const result = (flowCheckerCallback: FlowChecker) => {
|
|
321
325
|
const checkerResult = registerFlowChecker.call(
|
|
322
326
|
typesCollections.get(this),
|
|
323
327
|
flowCheckerCallback
|