@tsonic/core 10.0.3 → 10.0.9

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 CHANGED
@@ -188,6 +188,60 @@ export declare function trycast<T>(value: unknown): T | null;
188
188
  */
189
189
  export declare function asinterface<T>(value: unknown): T;
190
190
 
191
+ /**
192
+ * Makes a CLR interface type implementable in TypeScript without requiring
193
+ * internal `__tsonic_iface_*` nominal brand fields.
194
+ *
195
+ * Use ONLY in `implements` clauses.
196
+ *
197
+ * @example
198
+ * ```ts
199
+ * import type { Interface } from "@tsonic/core/lang.js";
200
+ * import type { IDesignTimeDbContextFactory } from "@tsonic/efcore/Microsoft.EntityFrameworkCore.Design.js";
201
+ *
202
+ * export class MyFactory implements Interface<IDesignTimeDbContextFactory<MyDbContext>> {
203
+ * CreateDbContext(_args: string[]): MyDbContext {
204
+ * return new MyDbContext();
205
+ * }
206
+ * }
207
+ * ```
208
+ */
209
+ export type Interface<T> = {
210
+ [K in keyof T as K extends `__tsonic_iface_${string}` ? never : K]: T[K];
211
+ };
212
+
213
+ /**
214
+ * Parameter passing modifiers (call-site markers).
215
+ *
216
+ * These are compile-time-only intrinsics. The compiler must erase them and emit
217
+ * the corresponding C# argument modifiers: `out`, `ref`, `in`.
218
+ *
219
+ * These are *not* runtime functions.
220
+ *
221
+ * @example
222
+ * ```ts
223
+ * import { defaultof, out } from "@tsonic/core/lang.js";
224
+ *
225
+ * let value = defaultof<int>();
226
+ * if (dict.TryGetValue("key", out(value))) {
227
+ * // value is assigned by the call
228
+ * }
229
+ * ```
230
+ */
231
+ export declare function out<T>(value: T): T;
232
+
233
+ /**
234
+ * Compile-time-only `ref` argument marker (emits `ref x`).
235
+ */
236
+ export declare function ref<T>(value: T): T;
237
+
238
+ /**
239
+ * Compile-time-only `in` argument marker (emits `in x`).
240
+ *
241
+ * Named `inref` because `in` is a TypeScript reserved keyword.
242
+ */
243
+ export declare function inref<T>(value: T): T;
244
+
191
245
  /**
192
246
  * Compile-time-only type selection marker.
193
247
  *
@@ -240,6 +294,49 @@ export declare function istype<T>(value: unknown): value is T;
240
294
  */
241
295
  export type thisarg<T> = T;
242
296
 
297
+ // ============================================================================
298
+ // Sticky Extension Scopes (used by generated bindings)
299
+ // ============================================================================
300
+
301
+ type __TsonicUnionToIntersection<T> =
302
+ (T extends unknown ? (k: T) => void : never) extends (k: infer I) => void ? I : never;
303
+
304
+ type __TsonicExtMapOf<T> = T extends { __tsonic_ext?: infer M } ? M : {};
305
+
306
+ type __TsonicExtApplierUnion<T> = __TsonicExtMapOf<T>[keyof __TsonicExtMapOf<T>];
307
+
308
+ type __TsonicApplyApplier<TApplier, TShape> =
309
+ TApplier extends { __tsonic_type: unknown }
310
+ ? (TApplier & { __tsonic_shape: TShape })["__tsonic_type"]
311
+ : never;
312
+
313
+ type __TsonicApplyAllAppliers<TReceiver, TShape> =
314
+ [__TsonicExtApplierUnion<TReceiver>] extends [never]
315
+ ? {}
316
+ : __TsonicUnionToIntersection<
317
+ __TsonicExtApplierUnion<TReceiver> extends infer A
318
+ ? A extends unknown
319
+ ? __TsonicApplyApplier<A, TShape>
320
+ : never
321
+ : never
322
+ >;
323
+
324
+ type __TsonicExtCarrier<TReceiver> =
325
+ TReceiver extends { __tsonic_ext?: infer M } ? { __tsonic_ext?: M } : {};
326
+
327
+ /**
328
+ * Rewrap a return shape with the extension scopes that were in scope on the receiver.
329
+ *
330
+ * This is used by generated `ExtensionMethods_*` typings so fluent chains keep the same
331
+ * extension namespaces "sticky" (similar to C# `using` semantics).
332
+ *
333
+ * This is compile-time-only. There is no runtime behavior.
334
+ */
335
+ export type Rewrap<TReceiver, TNewShape> =
336
+ TNewShape extends null | undefined ? TNewShape
337
+ : TNewShape extends void ? void
338
+ : TNewShape & __TsonicExtCarrier<TReceiver> & __TsonicApplyAllAppliers<TReceiver, TNewShape>;
339
+
243
340
  // ============================================================================
244
341
  // Span type (for stackalloc return type)
245
342
  // ============================================================================
package/lang.js ADDED
@@ -0,0 +1,3 @@
1
+ // Runtime stub for @tsonic/core/lang.js
2
+ // Tsonic erases these imports during compilation.
3
+ export {};
package/lang.js.d.ts ADDED
@@ -0,0 +1 @@
1
+ export * from "./lang.d.ts";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tsonic/core",
3
- "version": "10.0.3",
3
+ "version": "10.0.9",
4
4
  "description": "Core type definitions for Tsonic (versioned by .NET major)",
5
5
  "type": "module",
6
6
  "keywords": [