Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion packages/compiler/src/frontend/lowering/lowerer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -771,6 +771,11 @@ export function dynFallbackType(L: Lowerer, node: ts.Node, t: ts.Type): IrType |
if (t.flags & ts.TypeFlags.Void) return null;
if (!isJsSourceFile(node.getSourceFile())) {
if (t.flags & ts.TypeFlags.Any) return DYN;
// In --dynamic mode, `unknown` maps to the checked-dynamic type (same as
// `any`). This lets error handlers with `unknown`-typed catch bindings or
// parameters use instanceof Error, typeof checks, and dyn-compatible
// operations without SC2020 fences.
if (L.dynamic && (t.flags & ts.TypeFlags.Unknown)) return DYN;
// TS single-call-signature function types: per-piece fallback, but
// ONLY `any` pieces fall to dyn — any other unmappable piece keeps
// the whole type's own fence.
Expand Down Expand Up @@ -6118,8 +6123,10 @@ export class Lowerer {
// Marshalable CLOSURES cross as host functions — a record carrying
// methods (the service-registry entry: `{ label, load: () =>
// Promise<any>, defaultFallback: (cfg) => any }`) lifts field by
// field like any other.
// field like any other. In --dynamic mode, any function is liftable
// via jsMarshal (host function wrap) — the runtime handles type mismatches.
if (t.kind === "func") {
if (this.dynamic) return true;
return canMarshalTypedFuncIntoIsland(t, (id) => this.shapes.get(id), (id) => this.unions.get(id));
}
if (t.kind === "record") {
Expand Down
11 changes: 9 additions & 2 deletions packages/compiler/src/frontend/ts7/checker.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { InternalCompilerError } from "../../errors.js";
/* The checker facade: 5.9.3-shaped TypeChecker methods over 7.0.2's sync
* client, built around the survey's feasibility verdict. Naive per-call use
* of the 7.0.2 client costs 0.1-0.3 ms of IPC per query; the census counted
Expand Down Expand Up @@ -259,7 +258,7 @@ export class CheckerFacade {

private requireProject(): Project {
const project = this.options.project;
if (!project) throw new InternalCompilerError("CheckerFacade built without a project cannot resolve declarations");
if (!project) throw new Error("CheckerFacade built without a project cannot resolve declarations");
return project;
}

Expand Down Expand Up @@ -619,6 +618,14 @@ export class CheckerFacade {
return base;
}

/** Returns the base constraint of a TypeParameter, or undefined if none.
* Delegates directly to the raw checker — no memoization needed since this
* is only called in the constraint-fallback path (rare, uninstantiated
* generics) and the result is used only for JSVAL/null classification. */
getBaseConstraintOfType(type: Type): Type | undefined {
return this.raw.getBaseConstraintOfType(type);
}

private intrinsic(name: string, fetch: () => Type): Type {
let type = this.intrinsics.get(name);
if (type === undefined) {
Expand Down
Loading