@vicin/sigil 2.2.1 → 3.0.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/CHANGELOG.md +20 -0
- package/README.md +55 -188
- package/dist/index.d.mts +79 -160
- package/dist/index.d.ts +79 -160
- package/dist/index.global.js +4 -2379
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +1 -659
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1 -643
- package/dist/index.mjs.map +1 -1
- package/package.json +12 -3
package/dist/index.d.mts
CHANGED
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
/** -----------------------------------------
|
|
2
|
+
* Nominal identity symbol
|
|
3
|
+
* ----------------------------------------- */
|
|
4
|
+
/**
|
|
5
|
+
* Symbol used for nominal typing
|
|
6
|
+
*/
|
|
7
|
+
declare const sigil: unique symbol;
|
|
1
8
|
/** -----------------------------------------
|
|
2
9
|
* Class and instance
|
|
3
10
|
* ----------------------------------------- */
|
|
@@ -9,23 +16,13 @@
|
|
|
9
16
|
* predicates implemented by the `Sigilify` mixin.
|
|
10
17
|
*
|
|
11
18
|
* @template L - Narrow string literal type representing the label.
|
|
12
|
-
* @template P - Optinal parent to extend its '
|
|
19
|
+
* @template P - Optinal parent to extend its '[sigil]'.
|
|
13
20
|
*/
|
|
14
|
-
interface ISigilStatic<L extends string = string
|
|
15
|
-
/**
|
|
16
|
-
* Compile-time nominal brand that encodes the class label `L` plus parent's brand keys `BrandOf<P>`.
|
|
17
|
-
*
|
|
18
|
-
* - HAVE NO RUN-TIME VALUE (undefined)
|
|
19
|
-
* - Provides a *type-only* unique marker that makes instances nominally
|
|
20
|
-
* distinct by label and allows propagation/merging of brand keys across inheritance.
|
|
21
|
-
*/
|
|
22
|
-
readonly __SIGIL_BRAND__: Prettify<{
|
|
23
|
-
[k in L]: true;
|
|
24
|
-
} & SigilBrandOf<P>>;
|
|
21
|
+
interface ISigilStatic<L extends string = string> {
|
|
25
22
|
/** Class-level label constant (identity). */
|
|
26
|
-
readonly SigilLabel:
|
|
23
|
+
readonly SigilLabel: L;
|
|
27
24
|
/** Class-level label constant (human readable). */
|
|
28
|
-
readonly SigilEffectiveLabel:
|
|
25
|
+
readonly SigilEffectiveLabel: L;
|
|
29
26
|
/**
|
|
30
27
|
* Copy of the linearized sigil type label chain for the current constructor.
|
|
31
28
|
* Useful for debugging and strict lineage comparisons.
|
|
@@ -60,7 +57,7 @@ interface ISigilStatic<L extends string = string, P extends Function = never> {
|
|
|
60
57
|
* @param other - The object to test.
|
|
61
58
|
* @returns A type guard asserting `other` is an instance of the constructor.
|
|
62
59
|
*/
|
|
63
|
-
isOfType<T extends ISigilStatic>(this: T, other: unknown): other is
|
|
60
|
+
isOfType<T extends ISigilStatic>(this: T, other: unknown): other is T;
|
|
64
61
|
/**
|
|
65
62
|
* Strict lineage comparison: verifies that the calling constructor's type
|
|
66
63
|
* lineage (by label) matches the `other`'s lineage element-by-element.
|
|
@@ -73,14 +70,14 @@ interface ISigilStatic<L extends string = string, P extends Function = never> {
|
|
|
73
70
|
* @param other - The object to test.
|
|
74
71
|
* @returns A type guard asserting `other` is an instance whose lineage matches exactly.
|
|
75
72
|
*/
|
|
76
|
-
isOfTypeStrict<T extends ISigilStatic>(this: T, other: unknown): other is
|
|
73
|
+
isOfTypeStrict<T extends ISigilStatic>(this: T, other: unknown): other is T;
|
|
77
74
|
}
|
|
78
75
|
/**
|
|
79
76
|
* Instance-side interface describing properties present on sigil instances.
|
|
80
77
|
* The methods mirror the instance helpers injected by the mixin.
|
|
81
78
|
*
|
|
82
79
|
* @template L - Narrow string literal type for the label returned by `getSigilLabel`.
|
|
83
|
-
* @template P - Optinal parent to extend its '
|
|
80
|
+
* @template P - Optinal parent to extend its '[sigil]'.
|
|
84
81
|
*/
|
|
85
82
|
interface ISigilInstance<L extends string = string, P extends Function = never> {
|
|
86
83
|
/**
|
|
@@ -90,9 +87,9 @@ interface ISigilInstance<L extends string = string, P extends Function = never>
|
|
|
90
87
|
* - Provides a *type-only* unique marker that makes instances nominally
|
|
91
88
|
* distinct by label and allows propagation/merging of brand keys across inheritance.
|
|
92
89
|
*/
|
|
93
|
-
readonly
|
|
90
|
+
readonly [sigil]: Prettify<IfNever<SigilOf<P>, {}> & {
|
|
94
91
|
[k in L]: true;
|
|
95
|
-
}
|
|
92
|
+
}>;
|
|
96
93
|
/** Returns identity sigil label of the class constructor. */
|
|
97
94
|
getSigilLabel(): string;
|
|
98
95
|
/** Returns human-readable sigil label of the class constructor. */
|
|
@@ -114,7 +111,7 @@ interface ISigilInstance<L extends string = string, P extends Function = never>
|
|
|
114
111
|
* @param other - The object to test.
|
|
115
112
|
* @returns A type guard asserting `other` is an instance of the constructor.
|
|
116
113
|
*/
|
|
117
|
-
isOfType<T extends ISigilInstance>(this: T, other: unknown): other is
|
|
114
|
+
isOfType<T extends ISigilInstance>(this: T, other: unknown): other is T;
|
|
118
115
|
/**
|
|
119
116
|
* Strict lineage comparison: verifies that the calling constructor's type
|
|
120
117
|
* lineage (by label) matches the `other`'s lineage element-by-element.
|
|
@@ -127,66 +124,31 @@ interface ISigilInstance<L extends string = string, P extends Function = never>
|
|
|
127
124
|
* @param other - The object to test.
|
|
128
125
|
* @returns A type guard asserting `other` is an instance whose lineage matches exactly.
|
|
129
126
|
*/
|
|
130
|
-
isOfTypeStrict<T extends ISigilInstance>(this: T, other: unknown): other is
|
|
127
|
+
isOfTypeStrict<T extends ISigilInstance>(this: T, other: unknown): other is T;
|
|
131
128
|
}
|
|
132
129
|
/**
|
|
133
130
|
* Combined constructor + static interface for a sigil class.
|
|
134
131
|
*
|
|
135
132
|
* @template L - Narrow string literal type for the label.
|
|
136
|
-
* @template P - Optinal parent to extend its '
|
|
133
|
+
* @template P - Optinal parent to extend its '[sigil]'.
|
|
137
134
|
*/
|
|
138
|
-
type ISigil<L extends string = string, P extends Function = never> = ConstructorAbstract<ISigilInstance<L, P>> & ISigilStatic<L
|
|
139
|
-
/**
|
|
140
|
-
|
|
141
|
-
|
|
135
|
+
type ISigil<L extends string = string, P extends Function = never> = ConstructorAbstract<ISigilInstance<L, P>> & ISigilStatic<L>;
|
|
136
|
+
/** Update '[sigil]' field when manual typing is used. */
|
|
137
|
+
type ExtendSigil<L extends string, P extends ISigilInstance> = Prettify<IfNever<SigilOf<P>, {}> & {
|
|
138
|
+
[K in L]: true;
|
|
139
|
+
}>;
|
|
142
140
|
/**
|
|
143
|
-
*
|
|
144
|
-
* while inheriting/propagating compile-time brands from an optional parent sigil `P`.
|
|
141
|
+
* Extract the compile-time brand map from a sigil instance `S`.
|
|
145
142
|
*
|
|
146
|
-
* @
|
|
147
|
-
* @
|
|
143
|
+
* @typeParam S - A sigil instance type.
|
|
144
|
+
* @returns The sigil brand record (e.g. `{ User: true, Admin: true }`) or never if not Sigil class instance.
|
|
148
145
|
*/
|
|
149
|
-
type
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
* @remark Return same type is passed type has no 'prototype'
|
|
153
|
-
*/
|
|
154
|
-
type GetInstance<T> = T extends {
|
|
155
|
-
prototype: infer R;
|
|
156
|
-
} ? PrettifyBrand<R & {
|
|
157
|
-
__SIGIL_BRAND__: SigilBrandOf<T>;
|
|
158
|
-
}> : T;
|
|
159
|
-
/** Helper to append label into a class. */
|
|
160
|
-
type AppendLabel<L extends string> = {
|
|
161
|
-
readonly __SIGIL_BRAND__: Prettify<{
|
|
162
|
-
[K in L]: true;
|
|
163
|
-
}>;
|
|
164
|
-
};
|
|
165
|
-
/** -----------------------------------------
|
|
166
|
-
* Manual pattern types
|
|
167
|
-
* ----------------------------------------- */
|
|
168
|
-
/** Update '__SIGIL_BRAND__' field when manual typing is used. */
|
|
169
|
-
type UpdateSigilBrand<L extends string, P extends ISigilInstance> = Prettify<SigilBrandOf<P> & {
|
|
170
|
-
[K in L]: true;
|
|
171
|
-
}>;
|
|
146
|
+
type SigilOf<S> = S extends {
|
|
147
|
+
readonly [sigil]: infer Sigil;
|
|
148
|
+
} ? Sigil : never;
|
|
172
149
|
/** -----------------------------------------
|
|
173
150
|
* Generic types
|
|
174
151
|
* ----------------------------------------- */
|
|
175
|
-
/**
|
|
176
|
-
* Extract the compile-time brand map from a sigil constructor `S`.
|
|
177
|
-
*
|
|
178
|
-
* @typeParam S - A sigil constructor type (e.g. `typeof SomeSigilClass`).
|
|
179
|
-
* @returns The brand record carried on the constructor's instance type (e.g. `{ User: true, Admin: true }`).
|
|
180
|
-
*
|
|
181
|
-
* @remarks
|
|
182
|
-
* - This helper is used purely at the type level to compute the set of brand keys
|
|
183
|
-
* that should be propagated to derived sigils.
|
|
184
|
-
* - If `S` does not carry a `__SIGIL_BRAND__`, the resulting type is `never` and `IfNever<>`
|
|
185
|
-
* collapses it to an empty record.
|
|
186
|
-
*/
|
|
187
|
-
type SigilBrandOf<S> = IfNever<S extends {
|
|
188
|
-
readonly __SIGIL_BRAND__: infer Brand;
|
|
189
|
-
} ? Brand : never, Record<string, true>>;
|
|
190
152
|
/**
|
|
191
153
|
* Generic type for class constructors used by the Sigil utilities.
|
|
192
154
|
*
|
|
@@ -211,10 +173,6 @@ type ConstructorAbstract<T = object, P extends any[] = any[]> = abstract new (..
|
|
|
211
173
|
type Prettify<T> = {
|
|
212
174
|
[K in keyof T]: T[K];
|
|
213
175
|
} & {};
|
|
214
|
-
/** Helper type to prettify value, handles nested '__SIGIL_BRAND__' field */
|
|
215
|
-
type PrettifyBrand<T> = {
|
|
216
|
-
[K in keyof T]: K extends '__SIGIL_BRAND__' ? PrettifyBrand<T[K]> : T[K];
|
|
217
|
-
} & {};
|
|
218
176
|
/** Helper type to replace 'never' with another type */
|
|
219
177
|
type IfNever<T, R = {}> = [T] extends [never] ? R : T;
|
|
220
178
|
|
|
@@ -226,30 +184,27 @@ type IfNever<T, R = {}> = [T] extends [never] ? R : T;
|
|
|
226
184
|
*/
|
|
227
185
|
declare const Sigil: {
|
|
228
186
|
new (...args: any[]): {
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
};
|
|
232
|
-
isOfType<T>(this: T, other: unknown): other is GetInstance<T>;
|
|
233
|
-
isOfTypeStrict<T>(this: T, other: unknown): other is GetInstance<T>;
|
|
187
|
+
isOfType<T>(this: T, other: unknown): other is T;
|
|
188
|
+
isOfTypeStrict<T>(this: T, other: unknown): other is T;
|
|
234
189
|
getSigilLabel(): string;
|
|
235
190
|
getSigilEffectiveLabel(): string;
|
|
236
191
|
getSigilLabelLineage(): readonly string[];
|
|
237
192
|
getSigilLabelSet(): Readonly<Set<string>>;
|
|
193
|
+
readonly [sigil]: {
|
|
194
|
+
Sigil: true;
|
|
195
|
+
};
|
|
238
196
|
};
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
};
|
|
242
|
-
get SigilLabel(): string;
|
|
243
|
-
get SigilEffectiveLabel(): string;
|
|
197
|
+
get SigilLabel(): "Sigil";
|
|
198
|
+
get SigilEffectiveLabel(): "Sigil";
|
|
244
199
|
get SigilLabelLineage(): readonly string[];
|
|
245
200
|
get SigilLabelSet(): Readonly<Set<string>>;
|
|
246
201
|
isSigilified(obj: unknown): obj is ISigil;
|
|
247
|
-
isOfType<T>(this: T, other: unknown): other is
|
|
248
|
-
isOfTypeStrict<T>(this: T, other: unknown): other is
|
|
202
|
+
isOfType<T>(this: T, other: unknown): other is T;
|
|
203
|
+
isOfTypeStrict<T>(this: T, other: unknown): other is T;
|
|
249
204
|
} & {
|
|
250
205
|
new (): {};
|
|
251
206
|
};
|
|
252
|
-
type Sigil =
|
|
207
|
+
type Sigil = InstanceType<typeof Sigil>;
|
|
253
208
|
/**
|
|
254
209
|
* A sigil variant of the built-in `Error` constructor used by the library
|
|
255
210
|
* to represent Sigil-specific errors.
|
|
@@ -259,30 +214,26 @@ type Sigil = GetInstance<typeof Sigil>;
|
|
|
259
214
|
*/
|
|
260
215
|
declare const SigilError: {
|
|
261
216
|
new (...args: any[]): {
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
SigilError: true;
|
|
265
|
-
};
|
|
266
|
-
isOfType<T>(this: T, other: unknown): other is GetInstance<T>;
|
|
267
|
-
isOfTypeStrict<T>(this: T, other: unknown): other is GetInstance<T>;
|
|
217
|
+
isOfType<T>(this: T, other: unknown): other is T;
|
|
218
|
+
isOfTypeStrict<T>(this: T, other: unknown): other is T;
|
|
268
219
|
getSigilLabel(): string;
|
|
269
220
|
getSigilEffectiveLabel(): string;
|
|
270
221
|
getSigilLabelLineage(): readonly string[];
|
|
271
222
|
getSigilLabelSet(): Readonly<Set<string>>;
|
|
223
|
+
readonly [sigil]: {
|
|
224
|
+
Sigil: true;
|
|
225
|
+
SigilError: true;
|
|
226
|
+
};
|
|
272
227
|
};
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
SigilError: true;
|
|
276
|
-
};
|
|
277
|
-
get SigilLabel(): string;
|
|
278
|
-
get SigilEffectiveLabel(): string;
|
|
228
|
+
get SigilLabel(): "SigilError";
|
|
229
|
+
get SigilEffectiveLabel(): "SigilError";
|
|
279
230
|
get SigilLabelLineage(): readonly string[];
|
|
280
231
|
get SigilLabelSet(): Readonly<Set<string>>;
|
|
281
232
|
isSigilified(obj: unknown): obj is ISigil;
|
|
282
|
-
isOfType<T>(this: T, other: unknown): other is
|
|
283
|
-
isOfTypeStrict<T>(this: T, other: unknown): other is
|
|
233
|
+
isOfType<T>(this: T, other: unknown): other is T;
|
|
234
|
+
isOfTypeStrict<T>(this: T, other: unknown): other is T;
|
|
284
235
|
} & ErrorConstructor;
|
|
285
|
-
type SigilError =
|
|
236
|
+
type SigilError = InstanceType<typeof SigilError>;
|
|
286
237
|
|
|
287
238
|
/**
|
|
288
239
|
* Configuration options for the Sigil library.
|
|
@@ -371,18 +322,6 @@ declare function WithSigil<L extends string>(label?: L, opts?: SigilOptions): (v
|
|
|
371
322
|
* @returns The same constructor value, with runtime metadata ensured.
|
|
372
323
|
*/
|
|
373
324
|
declare function withSigil<S extends Function, L extends string = string>(Class: S, label?: L, opts?: SigilOptions): S;
|
|
374
|
-
/**
|
|
375
|
-
* Convenience helper that combine 'withSigil' and update 'SigilBrand'.
|
|
376
|
-
*
|
|
377
|
-
* @typeParam S - Constructor type (should be an ISigil).
|
|
378
|
-
* @typeParam L - Label literal to attach.
|
|
379
|
-
* @param Class - The constructor (class) to decorate and type.
|
|
380
|
-
* @param label - Optional label string. If omitted, a random label is generated.
|
|
381
|
-
* @param parent - Optional parent sigil constructor (type-only).
|
|
382
|
-
* @param opts - Options object to override any global options if needed.
|
|
383
|
-
* @returns The same constructor value, with runtime metadata ensured and typed as `TypedSigil<S,L,P>`.
|
|
384
|
-
*/
|
|
385
|
-
declare function withSigilTyped<S extends Function, L extends string = string>(Class: S, label?: L, opts?: SigilOptions): TypedSigil<S, L>;
|
|
386
325
|
|
|
387
326
|
/**
|
|
388
327
|
* Runtime predicate that checks whether the provided value is a sigil constructor.
|
|
@@ -398,7 +337,7 @@ declare function isSigilCtor(ctor: unknown): ctor is ISigil;
|
|
|
398
337
|
* @param inst - The instanca to test.
|
|
399
338
|
* @returns `true` if `obj` is an instance produced by a sigil constructor.
|
|
400
339
|
*/
|
|
401
|
-
declare function isSigilInstance(inst: unknown): inst is
|
|
340
|
+
declare function isSigilInstance(inst: unknown): inst is ISigilInstance;
|
|
402
341
|
/**
|
|
403
342
|
* Check whether the provided constructor was marked as a sigil base constructor.
|
|
404
343
|
*
|
|
@@ -412,7 +351,7 @@ declare function isSigilBaseCtor(ctor: Function): ctor is ISigil;
|
|
|
412
351
|
* @param inst - The instance to test.
|
|
413
352
|
* @returns `true` if `inst` is an instance of a sigil base constructor.
|
|
414
353
|
*/
|
|
415
|
-
declare function isSigilBaseInstance(inst: unknown): inst is
|
|
354
|
+
declare function isSigilBaseInstance(inst: unknown): inst is ISigilInstance;
|
|
416
355
|
/**
|
|
417
356
|
* Returns whether the constructor has been explicitly decorated with `WithSigil`.
|
|
418
357
|
*
|
|
@@ -442,16 +381,6 @@ declare function isInheritanceChecked(ctor: Function): boolean;
|
|
|
442
381
|
*/
|
|
443
382
|
declare function Sigilify<B extends Constructor, L extends string>(Base: B, label?: L, opts?: SigilOptions): {
|
|
444
383
|
new (...args: any[]): {
|
|
445
|
-
/**
|
|
446
|
-
* Compile-time nominal brand that encodes the class label `L` plus parent's brand keys `BrandOf<P>`.
|
|
447
|
-
*
|
|
448
|
-
* - HAVE NO RUN-TIME VALUE (undefined)
|
|
449
|
-
* - Provides a *type-only* unique marker that makes instances nominally
|
|
450
|
-
* distinct by label and allows propagation/merging of brand keys across inheritance.
|
|
451
|
-
*/
|
|
452
|
-
readonly __SIGIL_BRAND__: {
|
|
453
|
-
Sigil: true;
|
|
454
|
-
} & { [K_1 in L]: true; } extends infer T ? { [K in keyof T]: T[K]; } : never;
|
|
455
384
|
/**
|
|
456
385
|
* Check whether `other` is (or inherits from) the type instance.
|
|
457
386
|
*
|
|
@@ -462,7 +391,7 @@ declare function Sigilify<B extends Constructor, L extends string>(Base: B, labe
|
|
|
462
391
|
* @param other - The object to test.
|
|
463
392
|
* @returns `true` if `other` is the same instance of this type or a subtype.
|
|
464
393
|
*/
|
|
465
|
-
isOfType<
|
|
394
|
+
isOfType<T>(this: T, other: unknown): other is T;
|
|
466
395
|
/**
|
|
467
396
|
* Strict lineage check: compares the type label lineage arrays element-by-element.
|
|
468
397
|
*
|
|
@@ -473,7 +402,7 @@ declare function Sigilify<B extends Constructor, L extends string>(Base: B, labe
|
|
|
473
402
|
* @param other - The object to test.
|
|
474
403
|
* @returns `true` if `other` has an identical lineage up to the length of this instance's lineage.
|
|
475
404
|
*/
|
|
476
|
-
isOfTypeStrict<
|
|
405
|
+
isOfTypeStrict<T>(this: T, other: unknown): other is T;
|
|
477
406
|
/**
|
|
478
407
|
* Returns the identity sigil label of this instance's constructor.
|
|
479
408
|
*
|
|
@@ -498,25 +427,25 @@ declare function Sigilify<B extends Constructor, L extends string>(Base: B, labe
|
|
|
498
427
|
* @returns A Readonly Set of labels representing the type lineage for O(1) membership tests.
|
|
499
428
|
*/
|
|
500
429
|
getSigilLabelSet(): Readonly<Set<string>>;
|
|
430
|
+
/**
|
|
431
|
+
* Compile-time nominal brand that encodes the class label `L` plus parent's brand keys `BrandOf<P>`.
|
|
432
|
+
*
|
|
433
|
+
* - HAVE NO RUN-TIME VALUE (undefined)
|
|
434
|
+
* - Provides a *type-only* unique marker that makes instances nominally
|
|
435
|
+
* distinct by label and allows propagation/merging of brand keys across inheritance.
|
|
436
|
+
*/
|
|
437
|
+
readonly [sigil]: {
|
|
438
|
+
Sigil: true;
|
|
439
|
+
} & { [K_1 in L]: true; } extends infer T ? { [K in keyof T]: T[K]; } : never;
|
|
501
440
|
};
|
|
502
|
-
/**
|
|
503
|
-
* Compile-time nominal brand that encodes the class label `L` plus parent's brand keys `BrandOf<P>`.
|
|
504
|
-
*
|
|
505
|
-
* - HAVE NO RUN-TIME VALUE (undefined)
|
|
506
|
-
* - Provides a *type-only* unique marker that makes instances nominally
|
|
507
|
-
* distinct by label and allows propagation/merging of brand keys across inheritance.
|
|
508
|
-
*/
|
|
509
|
-
readonly __SIGIL_BRAND__: Prettify<{
|
|
510
|
-
Sigil: true;
|
|
511
|
-
} & { [K in L]: true; }>;
|
|
512
441
|
/**
|
|
513
442
|
* Class-level identity label constant for this sigil constructor.
|
|
514
443
|
*/
|
|
515
|
-
get SigilLabel():
|
|
444
|
+
get SigilLabel(): L;
|
|
516
445
|
/**
|
|
517
446
|
* Class-level human-readable label constant for this sigil constructor, last passed label in 'Sigil' chain by developer.
|
|
518
447
|
*/
|
|
519
|
-
get SigilEffectiveLabel():
|
|
448
|
+
get SigilEffectiveLabel(): L;
|
|
520
449
|
/**
|
|
521
450
|
* Copy of the linearized sigil type label chain for the current constructor.
|
|
522
451
|
*
|
|
@@ -551,7 +480,7 @@ declare function Sigilify<B extends Constructor, L extends string>(Base: B, labe
|
|
|
551
480
|
* @param other - The object to test.
|
|
552
481
|
* @returns `true` if `other` is an instance of this type or a subtype.
|
|
553
482
|
*/
|
|
554
|
-
isOfType<T>(this: T, other: unknown): other is
|
|
483
|
+
isOfType<T>(this: T, other: unknown): other is T;
|
|
555
484
|
/**
|
|
556
485
|
* Strict lineage check: compares the type label lineage arrays element-by-element.
|
|
557
486
|
*
|
|
@@ -560,7 +489,7 @@ declare function Sigilify<B extends Constructor, L extends string>(Base: B, labe
|
|
|
560
489
|
* @param other - The object to test.
|
|
561
490
|
* @returns `true` if `other` has an identical lineage up to the length of this constructor's lineage.
|
|
562
491
|
*/
|
|
563
|
-
isOfTypeStrict<T>(this: T, other: unknown): other is
|
|
492
|
+
isOfTypeStrict<T>(this: T, other: unknown): other is T;
|
|
564
493
|
} & B;
|
|
565
494
|
/**
|
|
566
495
|
* Mixin factory that augments an existing class with Sigil runtime metadata and helpers. Accept and return 'abstract' class.
|
|
@@ -573,16 +502,6 @@ declare function Sigilify<B extends Constructor, L extends string>(Base: B, labe
|
|
|
573
502
|
* @throws Error if `Base` is already sigilified.
|
|
574
503
|
*/
|
|
575
504
|
declare function SigilifyAbstract<B extends ConstructorAbstract, L extends string>(Base: B, label?: L, opts?: SigilOptions): ((abstract new (...args: any[]) => {
|
|
576
|
-
/**
|
|
577
|
-
* Compile-time nominal brand that encodes the class label `L` plus parent's brand keys `BrandOf<P>`.
|
|
578
|
-
*
|
|
579
|
-
* - HAVE NO RUN-TIME VALUE (undefined)
|
|
580
|
-
* - Provides a *type-only* unique marker that makes instances nominally
|
|
581
|
-
* distinct by label and allows propagation/merging of brand keys across inheritance.
|
|
582
|
-
*/
|
|
583
|
-
readonly __SIGIL_BRAND__: {
|
|
584
|
-
Sigil: true;
|
|
585
|
-
} & { [K_1 in L]: true; } extends infer T ? { [K in keyof T]: T[K]; } : never;
|
|
586
505
|
/**
|
|
587
506
|
* Check whether `other` is (or inherits from) the type instance.
|
|
588
507
|
*
|
|
@@ -593,7 +512,7 @@ declare function SigilifyAbstract<B extends ConstructorAbstract, L extends strin
|
|
|
593
512
|
* @param other - The object to test.
|
|
594
513
|
* @returns `true` if `other` is the same instance of this type or a subtype.
|
|
595
514
|
*/
|
|
596
|
-
isOfType<
|
|
515
|
+
isOfType<T>(this: T, other: unknown): other is T;
|
|
597
516
|
/**
|
|
598
517
|
* Strict lineage check: compares the type label lineage arrays element-by-element.
|
|
599
518
|
*
|
|
@@ -604,7 +523,7 @@ declare function SigilifyAbstract<B extends ConstructorAbstract, L extends strin
|
|
|
604
523
|
* @param other - The object to test.
|
|
605
524
|
* @returns `true` if `other` has an identical lineage up to the length of this instance's lineage.
|
|
606
525
|
*/
|
|
607
|
-
isOfTypeStrict<
|
|
526
|
+
isOfTypeStrict<T>(this: T, other: unknown): other is T;
|
|
608
527
|
/**
|
|
609
528
|
* Returns the identity sigil label of this instance's constructor.
|
|
610
529
|
*
|
|
@@ -629,7 +548,6 @@ declare function SigilifyAbstract<B extends ConstructorAbstract, L extends strin
|
|
|
629
548
|
* @returns A Readonly Set of labels representing the type lineage for O(1) membership tests.
|
|
630
549
|
*/
|
|
631
550
|
getSigilLabelSet(): Readonly<Set<string>>;
|
|
632
|
-
}) & {
|
|
633
551
|
/**
|
|
634
552
|
* Compile-time nominal brand that encodes the class label `L` plus parent's brand keys `BrandOf<P>`.
|
|
635
553
|
*
|
|
@@ -637,17 +555,18 @@ declare function SigilifyAbstract<B extends ConstructorAbstract, L extends strin
|
|
|
637
555
|
* - Provides a *type-only* unique marker that makes instances nominally
|
|
638
556
|
* distinct by label and allows propagation/merging of brand keys across inheritance.
|
|
639
557
|
*/
|
|
640
|
-
readonly
|
|
558
|
+
readonly [sigil]: {
|
|
641
559
|
Sigil: true;
|
|
642
|
-
} & { [
|
|
560
|
+
} & { [K_1 in L]: true; } extends infer T ? { [K in keyof T]: T[K]; } : never;
|
|
561
|
+
}) & {
|
|
643
562
|
/**
|
|
644
563
|
* Class-level identity label constant for this sigil constructor.
|
|
645
564
|
*/
|
|
646
|
-
get SigilLabel():
|
|
565
|
+
get SigilLabel(): L;
|
|
647
566
|
/**
|
|
648
567
|
* Class-level human-readable label constant for this sigil constructor, last passed label in 'Sigil' chain by developer.
|
|
649
568
|
*/
|
|
650
|
-
get SigilEffectiveLabel():
|
|
569
|
+
get SigilEffectiveLabel(): L;
|
|
651
570
|
/**
|
|
652
571
|
* Copy of the linearized sigil type label chain for the current constructor.
|
|
653
572
|
*
|
|
@@ -686,7 +605,7 @@ declare function SigilifyAbstract<B extends ConstructorAbstract, L extends strin
|
|
|
686
605
|
* @param other - The object to test.
|
|
687
606
|
* @returns `true` if `other` is an instance of this type or a subtype.
|
|
688
607
|
*/
|
|
689
|
-
isOfType<T>(this: T, other: unknown): other is
|
|
608
|
+
isOfType<T>(this: T, other: unknown): other is T;
|
|
690
609
|
/**
|
|
691
610
|
* Strict lineage check: compares the type label lineage arrays element-by-element.
|
|
692
611
|
*
|
|
@@ -699,7 +618,7 @@ declare function SigilifyAbstract<B extends ConstructorAbstract, L extends strin
|
|
|
699
618
|
* @param other - The object to test.
|
|
700
619
|
* @returns `true` if `other` has an identical lineage up to the length of this constructor's lineage.
|
|
701
620
|
*/
|
|
702
|
-
isOfTypeStrict<T>(this: T, other: unknown): other is
|
|
621
|
+
isOfTypeStrict<T>(this: T, other: unknown): other is T;
|
|
703
622
|
}) & B;
|
|
704
623
|
|
|
705
|
-
export { DEFAULT_LABEL_REGEX, type
|
|
624
|
+
export { DEFAULT_LABEL_REGEX, type ExtendSigil, type ISigil, type ISigilInstance, type ISigilStatic, Sigil, SigilError, type SigilOf, type SigilOptions, Sigilify, SigilifyAbstract, WithSigil, isDecorated, isInheritanceChecked, isSigilBaseCtor, isSigilBaseInstance, isSigilCtor, isSigilInstance, sigil, updateSigilOptions, withSigil };
|