@tsonic/core 10.0.9 → 10.0.11
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/lang.d.ts +197 -0
- package/package.json +2 -2
- package/runtime/bindings.json +34 -243
- package/runtime/internal/index.d.ts +38 -52
- package/attributes.d.ts +0 -192
|
@@ -9,15 +9,11 @@ import type { sbyte, byte, short, ushort, int, uint, long, ulong, int128, uint12
|
|
|
9
9
|
import type { ptr } from "@tsonic/core/types.js";
|
|
10
10
|
|
|
11
11
|
// Import types from other namespaces
|
|
12
|
-
import type {
|
|
13
|
-
import * as System_Internal from "@tsonic/dotnet/System
|
|
14
|
-
import type {
|
|
12
|
+
import type { Dictionary, IEnumerable, IList } from "@tsonic/dotnet/System.Collections.Generic.js";
|
|
13
|
+
import * as System_Internal from "@tsonic/dotnet/System.js";
|
|
14
|
+
import type { Action, Boolean as ClrBoolean, Func, IEquatable, Int32, Object as ClrObject, String as ClrString, Type, ValueType, Void } from "@tsonic/dotnet/System.js";
|
|
15
15
|
|
|
16
16
|
export interface IteratorResult_1$instance<T> {
|
|
17
|
-
readonly __tsonic_type_Tsonic_Runtime_IteratorResult_1: never;
|
|
18
|
-
|
|
19
|
-
readonly __tsonic_iface_System_IEquatable_1: never;
|
|
20
|
-
|
|
21
17
|
readonly done: boolean;
|
|
22
18
|
Done: boolean;
|
|
23
19
|
readonly value: T;
|
|
@@ -38,55 +34,50 @@ export const IteratorResult_1: {
|
|
|
38
34
|
export type IteratorResult_1<T> = IteratorResult_1$instance<T>;
|
|
39
35
|
|
|
40
36
|
export interface DictionaryAdapter_1$instance<T> {
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
readonly Keys: IEnumerable_1<System_Internal.String>;
|
|
45
|
-
readonly Values: IEnumerable_1<T | undefined>;
|
|
37
|
+
Item: T | undefined;
|
|
38
|
+
readonly Keys: IEnumerable<System_Internal.String>;
|
|
39
|
+
readonly Values: IEnumerable<T | undefined>;
|
|
46
40
|
ContainsKey(key: string): boolean;
|
|
47
|
-
GetDictionary():
|
|
41
|
+
GetDictionary(): Dictionary<System_Internal.String, unknown | undefined>;
|
|
48
42
|
}
|
|
49
43
|
|
|
50
44
|
|
|
51
45
|
export const DictionaryAdapter_1: {
|
|
52
|
-
new<T>(dictionary:
|
|
46
|
+
new<T>(dictionary: Dictionary<System_Internal.String, unknown>): DictionaryAdapter_1<T>;
|
|
53
47
|
};
|
|
54
48
|
|
|
55
49
|
|
|
56
50
|
export type DictionaryAdapter_1<T> = DictionaryAdapter_1$instance<T>;
|
|
57
51
|
|
|
58
52
|
export interface DynamicObject$instance {
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
[key: string]: unknown | undefined;
|
|
53
|
+
get Item(): unknown | undefined;
|
|
54
|
+
set Item(value: unknown);
|
|
62
55
|
GetKeys(): string[];
|
|
63
56
|
GetProperty<T>(key: string): T | undefined;
|
|
64
57
|
GetValues(): (unknown | undefined)[];
|
|
65
58
|
HasProperty(key: string): boolean;
|
|
66
59
|
SetProperty(key: string, value: unknown): void;
|
|
67
|
-
ToDictionary():
|
|
60
|
+
ToDictionary(): Dictionary<System_Internal.String, unknown | undefined>;
|
|
68
61
|
}
|
|
69
62
|
|
|
70
63
|
|
|
71
64
|
export const DynamicObject: {
|
|
72
65
|
new(): DynamicObject;
|
|
73
|
-
FromDictionary(properties:
|
|
66
|
+
FromDictionary(properties: Dictionary<System_Internal.String, unknown>): DynamicObject;
|
|
74
67
|
};
|
|
75
68
|
|
|
76
69
|
|
|
77
70
|
export type DynamicObject = DynamicObject$instance;
|
|
78
71
|
|
|
79
72
|
export interface Union_2$instance<T1, T2> {
|
|
80
|
-
readonly __tsonic_type_Tsonic_Runtime_Union_2: never;
|
|
81
|
-
|
|
82
73
|
As1(): T1;
|
|
83
74
|
As2(): T2;
|
|
84
75
|
Equals(obj: unknown): boolean;
|
|
85
76
|
GetHashCode(): int;
|
|
86
77
|
Is1(): boolean;
|
|
87
78
|
Is2(): boolean;
|
|
88
|
-
Match<TResult>(onT1:
|
|
89
|
-
Match(onT1:
|
|
79
|
+
Match<TResult>(onT1: Func<T1, TResult>, onT2: Func<T2, TResult>): TResult;
|
|
80
|
+
Match(onT1: Action<T1>, onT2: Action<T2>): void;
|
|
90
81
|
ToString(): string | undefined;
|
|
91
82
|
TryAs1(value: T1): boolean;
|
|
92
83
|
TryAs2(value: T2): boolean;
|
|
@@ -94,6 +85,7 @@ export interface Union_2$instance<T1, T2> {
|
|
|
94
85
|
|
|
95
86
|
|
|
96
87
|
export const Union_2: {
|
|
88
|
+
new<T1, T2>(): Union_2<T1, T2>;
|
|
97
89
|
From1<T1, T2>(value: T1): Union_2<T1, T2>;
|
|
98
90
|
From2<T1, T2>(value: T2): Union_2<T1, T2>;
|
|
99
91
|
};
|
|
@@ -102,8 +94,6 @@ export const Union_2: {
|
|
|
102
94
|
export type Union_2<T1, T2> = Union_2$instance<T1, T2>;
|
|
103
95
|
|
|
104
96
|
export interface Union_3$instance<T1, T2, T3> {
|
|
105
|
-
readonly __tsonic_type_Tsonic_Runtime_Union_3: never;
|
|
106
|
-
|
|
107
97
|
As1(): T1;
|
|
108
98
|
As2(): T2;
|
|
109
99
|
As3(): T3;
|
|
@@ -112,8 +102,8 @@ export interface Union_3$instance<T1, T2, T3> {
|
|
|
112
102
|
Is1(): boolean;
|
|
113
103
|
Is2(): boolean;
|
|
114
104
|
Is3(): boolean;
|
|
115
|
-
Match<TResult>(onT1:
|
|
116
|
-
Match(onT1:
|
|
105
|
+
Match<TResult>(onT1: Func<T1, TResult>, onT2: Func<T2, TResult>, onT3: Func<T3, TResult>): TResult;
|
|
106
|
+
Match(onT1: Action<T1>, onT2: Action<T2>, onT3: Action<T3>): void;
|
|
117
107
|
ToString(): string | undefined;
|
|
118
108
|
TryAs1(value: T1): boolean;
|
|
119
109
|
TryAs2(value: T2): boolean;
|
|
@@ -122,6 +112,7 @@ export interface Union_3$instance<T1, T2, T3> {
|
|
|
122
112
|
|
|
123
113
|
|
|
124
114
|
export const Union_3: {
|
|
115
|
+
new<T1, T2, T3>(): Union_3<T1, T2, T3>;
|
|
125
116
|
From1<T1, T2, T3>(value: T1): Union_3<T1, T2, T3>;
|
|
126
117
|
From2<T1, T2, T3>(value: T2): Union_3<T1, T2, T3>;
|
|
127
118
|
From3<T1, T2, T3>(value: T3): Union_3<T1, T2, T3>;
|
|
@@ -131,8 +122,6 @@ export const Union_3: {
|
|
|
131
122
|
export type Union_3<T1, T2, T3> = Union_3$instance<T1, T2, T3>;
|
|
132
123
|
|
|
133
124
|
export interface Union_4$instance<T1, T2, T3, T4> {
|
|
134
|
-
readonly __tsonic_type_Tsonic_Runtime_Union_4: never;
|
|
135
|
-
|
|
136
125
|
As1(): T1;
|
|
137
126
|
As2(): T2;
|
|
138
127
|
As3(): T3;
|
|
@@ -143,8 +132,8 @@ export interface Union_4$instance<T1, T2, T3, T4> {
|
|
|
143
132
|
Is2(): boolean;
|
|
144
133
|
Is3(): boolean;
|
|
145
134
|
Is4(): boolean;
|
|
146
|
-
Match<TResult>(onT1:
|
|
147
|
-
Match(onT1:
|
|
135
|
+
Match<TResult>(onT1: Func<T1, TResult>, onT2: Func<T2, TResult>, onT3: Func<T3, TResult>, onT4: Func<T4, TResult>): TResult;
|
|
136
|
+
Match(onT1: Action<T1>, onT2: Action<T2>, onT3: Action<T3>, onT4: Action<T4>): void;
|
|
148
137
|
ToString(): string | undefined;
|
|
149
138
|
TryAs1(value: T1): boolean;
|
|
150
139
|
TryAs2(value: T2): boolean;
|
|
@@ -154,6 +143,7 @@ export interface Union_4$instance<T1, T2, T3, T4> {
|
|
|
154
143
|
|
|
155
144
|
|
|
156
145
|
export const Union_4: {
|
|
146
|
+
new<T1, T2, T3, T4>(): Union_4<T1, T2, T3, T4>;
|
|
157
147
|
From1<T1, T2, T3, T4>(value: T1): Union_4<T1, T2, T3, T4>;
|
|
158
148
|
From2<T1, T2, T3, T4>(value: T2): Union_4<T1, T2, T3, T4>;
|
|
159
149
|
From3<T1, T2, T3, T4>(value: T3): Union_4<T1, T2, T3, T4>;
|
|
@@ -164,8 +154,6 @@ export const Union_4: {
|
|
|
164
154
|
export type Union_4<T1, T2, T3, T4> = Union_4$instance<T1, T2, T3, T4>;
|
|
165
155
|
|
|
166
156
|
export interface Union_5$instance<T1, T2, T3, T4, T5> {
|
|
167
|
-
readonly __tsonic_type_Tsonic_Runtime_Union_5: never;
|
|
168
|
-
|
|
169
157
|
As1(): T1;
|
|
170
158
|
As2(): T2;
|
|
171
159
|
As3(): T3;
|
|
@@ -178,8 +166,8 @@ export interface Union_5$instance<T1, T2, T3, T4, T5> {
|
|
|
178
166
|
Is3(): boolean;
|
|
179
167
|
Is4(): boolean;
|
|
180
168
|
Is5(): boolean;
|
|
181
|
-
Match<TResult>(onT1:
|
|
182
|
-
Match(onT1:
|
|
169
|
+
Match<TResult>(onT1: Func<T1, TResult>, onT2: Func<T2, TResult>, onT3: Func<T3, TResult>, onT4: Func<T4, TResult>, onT5: Func<T5, TResult>): TResult;
|
|
170
|
+
Match(onT1: Action<T1>, onT2: Action<T2>, onT3: Action<T3>, onT4: Action<T4>, onT5: Action<T5>): void;
|
|
183
171
|
ToString(): string | undefined;
|
|
184
172
|
TryAs1(value: T1): boolean;
|
|
185
173
|
TryAs2(value: T2): boolean;
|
|
@@ -190,6 +178,7 @@ export interface Union_5$instance<T1, T2, T3, T4, T5> {
|
|
|
190
178
|
|
|
191
179
|
|
|
192
180
|
export const Union_5: {
|
|
181
|
+
new<T1, T2, T3, T4, T5>(): Union_5<T1, T2, T3, T4, T5>;
|
|
193
182
|
From1<T1, T2, T3, T4, T5>(value: T1): Union_5<T1, T2, T3, T4, T5>;
|
|
194
183
|
From2<T1, T2, T3, T4, T5>(value: T2): Union_5<T1, T2, T3, T4, T5>;
|
|
195
184
|
From3<T1, T2, T3, T4, T5>(value: T3): Union_5<T1, T2, T3, T4, T5>;
|
|
@@ -201,8 +190,6 @@ export const Union_5: {
|
|
|
201
190
|
export type Union_5<T1, T2, T3, T4, T5> = Union_5$instance<T1, T2, T3, T4, T5>;
|
|
202
191
|
|
|
203
192
|
export interface Union_6$instance<T1, T2, T3, T4, T5, T6> {
|
|
204
|
-
readonly __tsonic_type_Tsonic_Runtime_Union_6: never;
|
|
205
|
-
|
|
206
193
|
As1(): T1;
|
|
207
194
|
As2(): T2;
|
|
208
195
|
As3(): T3;
|
|
@@ -217,8 +204,8 @@ export interface Union_6$instance<T1, T2, T3, T4, T5, T6> {
|
|
|
217
204
|
Is4(): boolean;
|
|
218
205
|
Is5(): boolean;
|
|
219
206
|
Is6(): boolean;
|
|
220
|
-
Match<TResult>(onT1:
|
|
221
|
-
Match(onT1:
|
|
207
|
+
Match<TResult>(onT1: Func<T1, TResult>, onT2: Func<T2, TResult>, onT3: Func<T3, TResult>, onT4: Func<T4, TResult>, onT5: Func<T5, TResult>, onT6: Func<T6, TResult>): TResult;
|
|
208
|
+
Match(onT1: Action<T1>, onT2: Action<T2>, onT3: Action<T3>, onT4: Action<T4>, onT5: Action<T5>, onT6: Action<T6>): void;
|
|
222
209
|
ToString(): string | undefined;
|
|
223
210
|
TryAs1(value: T1): boolean;
|
|
224
211
|
TryAs2(value: T2): boolean;
|
|
@@ -230,6 +217,7 @@ export interface Union_6$instance<T1, T2, T3, T4, T5, T6> {
|
|
|
230
217
|
|
|
231
218
|
|
|
232
219
|
export const Union_6: {
|
|
220
|
+
new<T1, T2, T3, T4, T5, T6>(): Union_6<T1, T2, T3, T4, T5, T6>;
|
|
233
221
|
From1<T1, T2, T3, T4, T5, T6>(value: T1): Union_6<T1, T2, T3, T4, T5, T6>;
|
|
234
222
|
From2<T1, T2, T3, T4, T5, T6>(value: T2): Union_6<T1, T2, T3, T4, T5, T6>;
|
|
235
223
|
From3<T1, T2, T3, T4, T5, T6>(value: T3): Union_6<T1, T2, T3, T4, T5, T6>;
|
|
@@ -242,8 +230,6 @@ export const Union_6: {
|
|
|
242
230
|
export type Union_6<T1, T2, T3, T4, T5, T6> = Union_6$instance<T1, T2, T3, T4, T5, T6>;
|
|
243
231
|
|
|
244
232
|
export interface Union_7$instance<T1, T2, T3, T4, T5, T6, T7> {
|
|
245
|
-
readonly __tsonic_type_Tsonic_Runtime_Union_7: never;
|
|
246
|
-
|
|
247
233
|
As1(): T1;
|
|
248
234
|
As2(): T2;
|
|
249
235
|
As3(): T3;
|
|
@@ -260,8 +246,8 @@ export interface Union_7$instance<T1, T2, T3, T4, T5, T6, T7> {
|
|
|
260
246
|
Is5(): boolean;
|
|
261
247
|
Is6(): boolean;
|
|
262
248
|
Is7(): boolean;
|
|
263
|
-
Match<TResult>(onT1:
|
|
264
|
-
Match(onT1:
|
|
249
|
+
Match<TResult>(onT1: Func<T1, TResult>, onT2: Func<T2, TResult>, onT3: Func<T3, TResult>, onT4: Func<T4, TResult>, onT5: Func<T5, TResult>, onT6: Func<T6, TResult>, onT7: Func<T7, TResult>): TResult;
|
|
250
|
+
Match(onT1: Action<T1>, onT2: Action<T2>, onT3: Action<T3>, onT4: Action<T4>, onT5: Action<T5>, onT6: Action<T6>, onT7: Action<T7>): void;
|
|
265
251
|
ToString(): string | undefined;
|
|
266
252
|
TryAs1(value: T1): boolean;
|
|
267
253
|
TryAs2(value: T2): boolean;
|
|
@@ -274,6 +260,7 @@ export interface Union_7$instance<T1, T2, T3, T4, T5, T6, T7> {
|
|
|
274
260
|
|
|
275
261
|
|
|
276
262
|
export const Union_7: {
|
|
263
|
+
new<T1, T2, T3, T4, T5, T6, T7>(): Union_7<T1, T2, T3, T4, T5, T6, T7>;
|
|
277
264
|
From1<T1, T2, T3, T4, T5, T6, T7>(value: T1): Union_7<T1, T2, T3, T4, T5, T6, T7>;
|
|
278
265
|
From2<T1, T2, T3, T4, T5, T6, T7>(value: T2): Union_7<T1, T2, T3, T4, T5, T6, T7>;
|
|
279
266
|
From3<T1, T2, T3, T4, T5, T6, T7>(value: T3): Union_7<T1, T2, T3, T4, T5, T6, T7>;
|
|
@@ -287,8 +274,6 @@ export const Union_7: {
|
|
|
287
274
|
export type Union_7<T1, T2, T3, T4, T5, T6, T7> = Union_7$instance<T1, T2, T3, T4, T5, T6, T7>;
|
|
288
275
|
|
|
289
276
|
export interface Union_8$instance<T1, T2, T3, T4, T5, T6, T7, T8> {
|
|
290
|
-
readonly __tsonic_type_Tsonic_Runtime_Union_8: never;
|
|
291
|
-
|
|
292
277
|
As1(): T1;
|
|
293
278
|
As2(): T2;
|
|
294
279
|
As3(): T3;
|
|
@@ -307,8 +292,8 @@ export interface Union_8$instance<T1, T2, T3, T4, T5, T6, T7, T8> {
|
|
|
307
292
|
Is6(): boolean;
|
|
308
293
|
Is7(): boolean;
|
|
309
294
|
Is8(): boolean;
|
|
310
|
-
Match<TResult>(onT1:
|
|
311
|
-
Match(onT1:
|
|
295
|
+
Match<TResult>(onT1: Func<T1, TResult>, onT2: Func<T2, TResult>, onT3: Func<T3, TResult>, onT4: Func<T4, TResult>, onT5: Func<T5, TResult>, onT6: Func<T6, TResult>, onT7: Func<T7, TResult>, onT8: Func<T8, TResult>): TResult;
|
|
296
|
+
Match(onT1: Action<T1>, onT2: Action<T2>, onT3: Action<T3>, onT4: Action<T4>, onT5: Action<T5>, onT6: Action<T6>, onT7: Action<T7>, onT8: Action<T8>): void;
|
|
312
297
|
ToString(): string | undefined;
|
|
313
298
|
TryAs1(value: T1): boolean;
|
|
314
299
|
TryAs2(value: T2): boolean;
|
|
@@ -322,6 +307,7 @@ export interface Union_8$instance<T1, T2, T3, T4, T5, T6, T7, T8> {
|
|
|
322
307
|
|
|
323
308
|
|
|
324
309
|
export const Union_8: {
|
|
310
|
+
new<T1, T2, T3, T4, T5, T6, T7, T8>(): Union_8<T1, T2, T3, T4, T5, T6, T7, T8>;
|
|
325
311
|
From1<T1, T2, T3, T4, T5, T6, T7, T8>(value: T1): Union_8<T1, T2, T3, T4, T5, T6, T7, T8>;
|
|
326
312
|
From2<T1, T2, T3, T4, T5, T6, T7, T8>(value: T2): Union_8<T1, T2, T3, T4, T5, T6, T7, T8>;
|
|
327
313
|
From3<T1, T2, T3, T4, T5, T6, T7, T8>(value: T3): Union_8<T1, T2, T3, T4, T5, T6, T7, T8>;
|
|
@@ -336,8 +322,8 @@ export const Union_8: {
|
|
|
336
322
|
export type Union_8<T1, T2, T3, T4, T5, T6, T7, T8> = Union_8$instance<T1, T2, T3, T4, T5, T6, T7, T8>;
|
|
337
323
|
|
|
338
324
|
export abstract class ArrayHelpers$instance {
|
|
339
|
-
static Slice<T>(source:
|
|
340
|
-
static Slice<T>(source:
|
|
325
|
+
static Slice<T>(source: IEnumerable<T>, startIndex: int): T[];
|
|
326
|
+
static Slice<T>(source: IList<T>, startIndex: int): T[];
|
|
341
327
|
static Slice<T>(source: T[], startIndex: int): T[];
|
|
342
328
|
}
|
|
343
329
|
|
|
@@ -354,9 +340,9 @@ export type Operators = Operators$instance;
|
|
|
354
340
|
|
|
355
341
|
export abstract class Structural$instance {
|
|
356
342
|
static Clone<T>(source: unknown): T | undefined;
|
|
357
|
-
static CloneFromDictionary<T>(source:
|
|
358
|
-
static CreateDictionaryAdapter<T>(source:
|
|
359
|
-
static ToDictionary(source: unknown):
|
|
343
|
+
static CloneFromDictionary<T>(source: Dictionary<System_Internal.String, unknown>): T | undefined;
|
|
344
|
+
static CreateDictionaryAdapter<T>(source: Dictionary<System_Internal.String, unknown>): DictionaryAdapter_1<T>;
|
|
345
|
+
static ToDictionary(source: unknown): Dictionary<System_Internal.String, unknown | undefined>;
|
|
360
346
|
}
|
|
361
347
|
|
|
362
348
|
|
package/attributes.d.ts
DELETED
|
@@ -1,192 +0,0 @@
|
|
|
1
|
-
// @tsonic/core/attributes.d.ts
|
|
2
|
-
|
|
3
|
-
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Compiler-only attribute API for Tsonic.
|
|
7
|
-
*
|
|
8
|
-
* Design goals:
|
|
9
|
-
* - Clean, consistent, "compiler-grade" surface area.
|
|
10
|
-
* - Fully type-safe selection of targets (type / ctor / method / property).
|
|
11
|
-
* - Attributes are represented as:
|
|
12
|
-
* - A constructor reference (e.g., ObsoleteAttribute)
|
|
13
|
-
* - Optional ctor args (typed via ConstructorParameters)
|
|
14
|
-
* - Optional helper `A.attr(...)` to build an attribute descriptor (also typed).
|
|
15
|
-
*
|
|
16
|
-
* Runtime note:
|
|
17
|
-
* This module is expected to be erased/ignored by the compiler pipeline.
|
|
18
|
-
*/
|
|
19
|
-
|
|
20
|
-
/** A class constructor type. */
|
|
21
|
-
export type Ctor<T = unknown, Args extends readonly any[] = readonly any[]> = new (
|
|
22
|
-
...args: Args
|
|
23
|
-
) => T;
|
|
24
|
-
|
|
25
|
-
/** Any attribute class constructor. */
|
|
26
|
-
export type AttributeCtor = Ctor<object, readonly any[]>;
|
|
27
|
-
|
|
28
|
-
/**
|
|
29
|
-
* Extract constructor parameters across multiple overloads.
|
|
30
|
-
*
|
|
31
|
-
* TypeScript's built-in ConstructorParameters<C> collapses overloads to the
|
|
32
|
-
* last signature, which makes attribute ctor typing unusably strict for many
|
|
33
|
-
* .NET attributes.
|
|
34
|
-
*/
|
|
35
|
-
export type OverloadedConstructorParameters<C extends AttributeCtor> =
|
|
36
|
-
C extends {
|
|
37
|
-
new (...args: infer A1): any;
|
|
38
|
-
new (...args: infer A2): any;
|
|
39
|
-
new (...args: infer A3): any;
|
|
40
|
-
new (...args: infer A4): any;
|
|
41
|
-
new (...args: infer A5): any;
|
|
42
|
-
}
|
|
43
|
-
? A1 | A2 | A3 | A4 | A5
|
|
44
|
-
: C extends {
|
|
45
|
-
new (...args: infer A1): any;
|
|
46
|
-
new (...args: infer A2): any;
|
|
47
|
-
new (...args: infer A3): any;
|
|
48
|
-
new (...args: infer A4): any;
|
|
49
|
-
}
|
|
50
|
-
? A1 | A2 | A3 | A4
|
|
51
|
-
: C extends {
|
|
52
|
-
new (...args: infer A1): any;
|
|
53
|
-
new (...args: infer A2): any;
|
|
54
|
-
new (...args: infer A3): any;
|
|
55
|
-
}
|
|
56
|
-
? A1 | A2 | A3
|
|
57
|
-
: C extends { new (...args: infer A1): any; new (...args: infer A2): any }
|
|
58
|
-
? A1 | A2
|
|
59
|
-
: C extends { new (...args: infer A): any }
|
|
60
|
-
? A
|
|
61
|
-
: never;
|
|
62
|
-
|
|
63
|
-
/** Attribute application (constructor + ctor arguments). */
|
|
64
|
-
export interface AttributeDescriptor<C extends AttributeCtor = AttributeCtor> {
|
|
65
|
-
readonly kind: "attribute";
|
|
66
|
-
readonly ctor: C;
|
|
67
|
-
readonly args: readonly OverloadedConstructorParameters<C>;
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
/** Extract instance type of a constructor. */
|
|
71
|
-
export type InstanceOf<C extends Ctor<any, any>> = C extends Ctor<infer I, any>
|
|
72
|
-
? I
|
|
73
|
-
: never;
|
|
74
|
-
|
|
75
|
-
/** Keys of T whose values are callable. */
|
|
76
|
-
export type MethodKeys<T> = {
|
|
77
|
-
[K in keyof T]-?: T[K] extends (...args: any[]) => any ? K : never;
|
|
78
|
-
}[keyof T];
|
|
79
|
-
|
|
80
|
-
/** Keys of T whose values are NOT callable (i.e., "properties"). */
|
|
81
|
-
export type PropertyKeys<T> = {
|
|
82
|
-
[K in keyof T]-?: T[K] extends (...args: any[]) => any ? never : K;
|
|
83
|
-
}[keyof T];
|
|
84
|
-
|
|
85
|
-
/**
|
|
86
|
-
* Inferred "method value type" from a method selector.
|
|
87
|
-
* The selector must resolve to a function-valued member on T.
|
|
88
|
-
*/
|
|
89
|
-
export type SelectedMethodValue<T> = (...args: any[]) => any;
|
|
90
|
-
|
|
91
|
-
/**
|
|
92
|
-
* Fluent builder returned from A.on(Foo).
|
|
93
|
-
* Allows attaching attributes to:
|
|
94
|
-
* - the type itself
|
|
95
|
-
* - the constructor
|
|
96
|
-
* - a method
|
|
97
|
-
* - a property
|
|
98
|
-
*/
|
|
99
|
-
export interface OnBuilder<T> {
|
|
100
|
-
/** Attach attributes to the type declaration (C# class/interface). */
|
|
101
|
-
type: AttributeTargetBuilder;
|
|
102
|
-
|
|
103
|
-
/** Attach attributes to the constructor. */
|
|
104
|
-
ctor: AttributeTargetBuilder;
|
|
105
|
-
|
|
106
|
-
/**
|
|
107
|
-
* Select a method to annotate.
|
|
108
|
-
*
|
|
109
|
-
* The selector must be a simple member access in practice (enforced by compiler),
|
|
110
|
-
* but is typed here as: (t: T) => T[K] where K is a method key.
|
|
111
|
-
*
|
|
112
|
-
* Example:
|
|
113
|
-
* A.on(User).method(u => u.save).add(TransactionAttribute);
|
|
114
|
-
*/
|
|
115
|
-
method<K extends MethodKeys<T>>(
|
|
116
|
-
selector: (t: T) => T[K]
|
|
117
|
-
): AttributeTargetBuilder;
|
|
118
|
-
|
|
119
|
-
/**
|
|
120
|
-
* Select a property to annotate.
|
|
121
|
-
*
|
|
122
|
-
* Example:
|
|
123
|
-
* A.on(User).prop(u => u.name).add(JsonPropertyNameAttribute, "name");
|
|
124
|
-
*/
|
|
125
|
-
prop<K extends PropertyKeys<T>>(
|
|
126
|
-
selector: (t: T) => T[K]
|
|
127
|
-
): AttributeTargetBuilder;
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
/**
|
|
131
|
-
* Target builder that supports adding attributes.
|
|
132
|
-
* Supports two canonical forms:
|
|
133
|
-
* - add(AttrCtor, ...args)
|
|
134
|
-
* - add(A.attr(AttrCtor, ...args))
|
|
135
|
-
*/
|
|
136
|
-
export interface AttributeTargetBuilder {
|
|
137
|
-
/**
|
|
138
|
-
* Add an attribute by constructor + arguments.
|
|
139
|
-
*
|
|
140
|
-
* Example:
|
|
141
|
-
* A.on(Config).type.add(ObsoleteAttribute, "Will be removed in v2");
|
|
142
|
-
*/
|
|
143
|
-
add<C extends AttributeCtor>(
|
|
144
|
-
ctor: C,
|
|
145
|
-
...args: OverloadedConstructorParameters<C>
|
|
146
|
-
): void;
|
|
147
|
-
|
|
148
|
-
/**
|
|
149
|
-
* Add an attribute descriptor produced by A.attr(...).
|
|
150
|
-
*
|
|
151
|
-
* Example:
|
|
152
|
-
* A.on(Config).type.add(A.attr(ObsoleteAttribute, "Will be removed in v2"));
|
|
153
|
-
*/
|
|
154
|
-
add<C extends AttributeCtor>(descriptor: AttributeDescriptor<C>): void;
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
/**
|
|
158
|
-
* The main entrypoint.
|
|
159
|
-
*
|
|
160
|
-
* Usage:
|
|
161
|
-
* import { attributes as A } from "@tsonic/core/attributes.js";
|
|
162
|
-
*
|
|
163
|
-
* class Config {}
|
|
164
|
-
* A.on(Config).type.add(SerializableAttribute);
|
|
165
|
-
* A.on(Config).type.add(ObsoleteAttribute, "Will be removed in v2");
|
|
166
|
-
*
|
|
167
|
-
* Emits:
|
|
168
|
-
* [System.SerializableAttribute]
|
|
169
|
-
* [System.ObsoleteAttribute("Will be removed in v2")]
|
|
170
|
-
*/
|
|
171
|
-
export interface AttributesApi {
|
|
172
|
-
/**
|
|
173
|
-
* Begin targeting a type by passing its constructor.
|
|
174
|
-
*/
|
|
175
|
-
on<C extends Ctor<any, any>>(ctor: C): OnBuilder<InstanceOf<C>>;
|
|
176
|
-
|
|
177
|
-
/**
|
|
178
|
-
* Build an attribute descriptor (compiler-known "attribute instance").
|
|
179
|
-
*
|
|
180
|
-
* Example:
|
|
181
|
-
* A.on(Config).type.add(A.attr(ObsoleteAttribute, "Will be removed in v2"));
|
|
182
|
-
*/
|
|
183
|
-
attr<C extends AttributeCtor>(
|
|
184
|
-
ctor: C,
|
|
185
|
-
...args: OverloadedConstructorParameters<C>
|
|
186
|
-
): AttributeDescriptor<C>;
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
/**
|
|
190
|
-
* Named export used by consumers.
|
|
191
|
-
*/
|
|
192
|
-
export declare const attributes: AttributesApi;
|