@tsonic/core 10.0.1 → 10.0.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.
Files changed (2) hide show
  1. package/lang.d.ts +46 -0
  2. package/package.json +1 -1
package/lang.d.ts CHANGED
@@ -169,6 +169,52 @@ export declare function nameof(expression: unknown): string;
169
169
  */
170
170
  export declare function trycast<T>(value: unknown): T | null;
171
171
 
172
+ /**
173
+ * Compile-time-only interface view.
174
+ *
175
+ * This is NOT a runtime cast. The compiler must erase this call before emitting C#.
176
+ *
177
+ * Primary use: treat a value as a CLR interface/nominal type for TypeScript type checking,
178
+ * without introducing runtime casts in emitted C# (important for EF Core precompilation).
179
+ *
180
+ * @example
181
+ * ```ts
182
+ * import { asinterface } from "@tsonic/core/lang.js";
183
+ * import type { IQueryable } from "@tsonic/dotnet/System.Linq.js";
184
+ *
185
+ * const q = asinterface<IQueryable<User>>(db.Users);
186
+ * // q is typed as IQueryable<User> in TS, but emits without a cast in C#.
187
+ * ```
188
+ */
189
+ export declare function asinterface<T>(value: unknown): T;
190
+
191
+ /**
192
+ * Compile-time-only type selection marker.
193
+ *
194
+ * This is NOT a runtime type test. The compiler must erase this call before emitting C#.
195
+ *
196
+ * Primary use: specialize a single TypeScript overload implementation into one CLR method
197
+ * per signature (e.g., overriding a protected virtual overload family).
198
+ *
199
+ * @example
200
+ * ```ts
201
+ * import { istype } from "@tsonic/core/lang.js";
202
+ * import type { int } from "@tsonic/core/types.js";
203
+ *
204
+ * // Overload signatures
205
+ * Foo(x: int): int;
206
+ * Foo(x: string): int;
207
+ *
208
+ * // Single implementation (compile-time specialized)
209
+ * Foo(p0: unknown): unknown {
210
+ * if (istype<int>(p0)) return p0 + 1;
211
+ * if (istype<string>(p0)) return p0.length;
212
+ * throw new Error("unreachable");
213
+ * }
214
+ * ```
215
+ */
216
+ export declare function istype<T>(value: unknown): value is T;
217
+
172
218
  // ============================================================================
173
219
  // Extension Method Intrinsics
174
220
  // ============================================================================
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tsonic/core",
3
- "version": "10.0.1",
3
+ "version": "10.0.3",
4
4
  "description": "Core type definitions for Tsonic (versioned by .NET major)",
5
5
  "type": "module",
6
6
  "keywords": [