Merge ni/i3-exports into ni/i4-deferred

Co-Authored-By: Claude 5.5 <noreply@anthropic.com>
This commit is contained in:
Malte Ubl
2026-10-27 19:35:32 -07:00
co-authored by Claude 5.5
3 changed files with 17 additions and 7 deletions
+14 -3
View File
@@ -3,7 +3,7 @@
// require() specifier) runs in a Node island: its objects cross as
// handles, so the same object returned twice is ===, and writes through
// one reference are visible through every other, on both sides.
import { Store, createStore, describe, VERSION, makePoint, addPoints, ping, makeTricky } from "islandkit";
import { Store, createStore, describe, VERSION, makePoint, addPoints, ping, makeTricky, type Tricky } from "islandkit";
import * as kit from "islandkit";
console.log(VERSION);
@@ -35,10 +35,21 @@ console.log(p.x, p.y);
p.x = 100;
console.log(p.x + p.y);
// JavaScript reads `tricky.method` before it evaluates `+tricky`, whose
// JavaScript reads `tricky.method` before it evaluates `+swapper`, whose
// valueOf replaces the method: the call must reach the original.
class Swapper {
target: Tricky;
constructor(target: Tricky) {
this.target = target;
}
valueOf(): number {
this.target.method = this.target.other;
return 1;
}
}
const tricky = makeTricky();
console.log("unary", tricky.method(+tricky), tricky.method(1));
const swapper = new Swapper(tricky);
console.log("unary", tricky.method(+swapper), tricky.method(1));
console.log(ping(), ping(), kit.ping());
+1 -1
View File
@@ -26,6 +26,6 @@ export declare let loads: number;
export declare function ping(): number;
export interface Tricky {
method(value: number): string;
valueOf(): number;
other(): string;
}
export declare function makeTricky(): Tricky;
+2 -3
View File
@@ -20,8 +20,7 @@ exports.makeTricky = () => ({
method() {
return "original";
},
valueOf() {
this.method = () => "replaced";
return 1;
other() {
return "replaced";
},
});