@tsonic/core 0.6.1 → 0.6.3

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/attributes.d.ts CHANGED
@@ -25,11 +25,46 @@ export type Ctor<T = unknown, Args extends readonly any[] = readonly any[]> = ne
25
25
  /** Any attribute class constructor. */
26
26
  export type AttributeCtor = Ctor<object, readonly any[]>;
27
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
+
28
63
  /** Attribute application (constructor + ctor arguments). */
29
64
  export interface AttributeDescriptor<C extends AttributeCtor = AttributeCtor> {
30
65
  readonly kind: "attribute";
31
66
  readonly ctor: C;
32
- readonly args: readonly ConstructorParameters<C>;
67
+ readonly args: readonly OverloadedConstructorParameters<C>;
33
68
  }
34
69
 
35
70
  /** Extract instance type of a constructor. */
@@ -107,7 +142,7 @@ export interface AttributeTargetBuilder {
107
142
  */
108
143
  add<C extends AttributeCtor>(
109
144
  ctor: C,
110
- ...args: ConstructorParameters<C>
145
+ ...args: OverloadedConstructorParameters<C>
111
146
  ): void;
112
147
 
113
148
  /**
@@ -147,7 +182,7 @@ export interface AttributesApi {
147
182
  */
148
183
  attr<C extends AttributeCtor>(
149
184
  ctor: C,
150
- ...args: ConstructorParameters<C>
185
+ ...args: OverloadedConstructorParameters<C>
151
186
  ): AttributeDescriptor<C>;
152
187
  }
153
188
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tsonic/core",
3
- "version": "0.6.1",
3
+ "version": "0.6.3",
4
4
  "description": "Core type definitions for Tsonic - TypeScript to native compiler",
5
5
  "type": "module",
6
6
  "keywords": [