Skip to content
Open
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
2 changes: 1 addition & 1 deletion apps/cloud/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"skipLibCheck": true,
"types": ["@cloudflare/workers-types"],
"outDir": "dist",
"rootDir": ".",
"rootDir": "../..",
"declaration": false,
"declarationMap": false,
"sourceMap": true,
Expand Down
2 changes: 1 addition & 1 deletion apps/local/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"esModuleInterop": true,
"skipLibCheck": true,
"outDir": "dist",
"rootDir": ".",
"rootDir": "../..",
"jsx": "react-jsx",
"types": ["bun-types"],
"plugins": [
Expand Down
95 changes: 66 additions & 29 deletions bun.lock

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion examples/all-plugins/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,6 @@
},
"devDependencies": {
"@types/node": "catalog:",
"typescript": "latest"
"typescript": "7.0.1-rc"
}
}
2 changes: 1 addition & 1 deletion examples/promise-sdk/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,6 @@
},
"devDependencies": {
"@types/node": "catalog:",
"typescript": "latest"
"typescript": "7.0.1-rc"
}
}
15 changes: 8 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -65,16 +65,16 @@
"release:publish:packages:prepare": "bun run scripts/publish-packages.ts --prepare-only",
"release:smoke:packages": "bun run scripts/smoke-test-packed.ts",
"clean": "bun run scripts/clean.ts",
"prepare": "effect-language-service patch && effect-tsgo patch && bun run --cwd packages/core/vite-plugin build:bundle && bun run --cwd packages/react build"
"prepare": "effect-tsgo patch && bun run --cwd packages/core/vite-plugin build:bundle && bun run --cwd packages/react build"
},
"dependencies": {},
"devDependencies": {
"@changesets/changelog-github": "^0.7.0",
"@changesets/cli": "^2.30.0",
"@effect/language-service": "^0.85.1",
"@effect/tsgo": "^0.5.2",
"@effect/language-service": "^0.86.2",
"@effect/tsgo": "^0.14.6",
"@effect/vitest": "catalog:",
"@typescript/native-preview": "^7.0.0-dev.20260410.1",
"@typescript/native-preview": "^7.0.0-dev.20260622.1",
"@vitest/expect": "catalog:",
"@vitest/mocker": "catalog:",
"@vitest/pretty-format": "catalog:",
Expand All @@ -88,7 +88,7 @@
"oxfmt": "^0.44.0",
"oxlint": "^1.56.0",
"turbo": "^2.5.6",
"typescript": "^5.9.3",
"typescript": "7.0.1-rc",
"vitest": "catalog:"
},
"packageManager": "bun@1.3.11",
Expand Down Expand Up @@ -121,7 +121,7 @@
"react-dom": "^19.1.0",
"@types/react": "^19.1.0",
"@types/react-dom": "^19.1.0",
"typescript": "^5.9.3",
"typescript": "7.0.1-rc",
"tailwindcss": "^4.2.2",
"quickjs-emscripten": "^0.31.0",
"@jitl/quickjs-wasmfile-release-sync": "0.31.0",
Expand All @@ -131,6 +131,7 @@
"patchedDependencies": {
"postgres@3.4.9": "patches/postgres@3.4.9.patch",
"@cloudflare/vite-plugin@1.31.2": "patches/@cloudflare%2Fvite-plugin@1.31.2.patch",
"libsql@0.5.29": "patches/libsql@0.5.29.patch"
"libsql@0.5.29": "patches/libsql@0.5.29.patch",
"tsup@8.5.1": "patches/tsup@8.5.1.patch"
}
}
2 changes: 1 addition & 1 deletion packages/app/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"esModuleInterop": true,
"skipLibCheck": true,
"outDir": "dist",
"rootDir": ".",
"rootDir": "..",
"jsx": "react-jsx",
"types": ["vite/client"]
},
Expand Down
76 changes: 45 additions & 31 deletions packages/core/sdk/src/testing/tool-output-contract.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
import * as ts from "typescript";
import { spawnSync } from "node:child_process";
import { mkdtempSync, rmSync, writeFileSync } from "node:fs";
import { createRequire } from "node:module";
import { tmpdir } from "node:os";
import path from "node:path";

export type OutputTypeScriptContract = {
readonly outputTypeScript?: string;
Expand All @@ -12,6 +16,18 @@ export type TypeCheckOutputTypeScriptOptions = {
readonly valueName?: string;
};

// TypeScript 7 (the native compiler) removed the classic `require("typescript")`
// JS API, so we type-check the synthesized snippet by invoking the native `tsgo`
// binary against a throwaway file. The binary is resolved through the
// `@typescript/native-preview` shim, which locates the right platform build.
const resolveTsgoShim = (): string => {
const require = createRequire(import.meta.url);
const packageJson = require.resolve("@typescript/native-preview/package.json");
return path.join(path.dirname(packageJson), "bin", "tsgo.js");
};

const ERROR_LINE = /: error TS\d+:/;

export const typeCheckOutputTypeScript = (
contract: OutputTypeScriptContract | null | undefined,
runtimeOutput: unknown,
Expand All @@ -33,34 +49,32 @@ export const typeCheckOutputTypeScript = (
options.consumerSource ?? `${valueName};`,
].join("\n");

const compilerOptions: ts.CompilerOptions = {
module: ts.ModuleKind.ESNext,
noEmit: true,
skipLibCheck: true,
strict: true,
target: ts.ScriptTarget.ES2022,
};
const host = ts.createCompilerHost(compilerOptions);
const originalGetSourceFile = host.getSourceFile.bind(host);
const originalReadFile = host.readFile.bind(host);
const originalFileExists = host.fileExists.bind(host);

host.getSourceFile = (candidate, languageVersion, onError, shouldCreateNewSourceFile) => {
if (candidate === fileName) {
return ts.createSourceFile(candidate, source, languageVersion, true);
}
return originalGetSourceFile(candidate, languageVersion, onError, shouldCreateNewSourceFile);
};
host.readFile = (candidate) => (candidate === fileName ? source : originalReadFile(candidate));
host.fileExists = (candidate) => candidate === fileName || originalFileExists(candidate);

const program = ts.createProgram([fileName], compilerOptions, host);
return ts.getPreEmitDiagnostics(program).map((diagnostic) => {
const message = ts.flattenDiagnosticMessageText(diagnostic.messageText, "\n");
if (!diagnostic.file || diagnostic.start === undefined) {
return message;
}
const position = diagnostic.file.getLineAndCharacterOfPosition(diagnostic.start);
return `${diagnostic.file.fileName}:${position.line + 1}:${position.character + 1} ${message}`;
});
const dir = mkdtempSync(path.join(tmpdir(), "tool-output-contract-"));
// oxlint-disable-next-line executor/no-try-catch-or-throw -- boundary: sync test helper that spawns the native tsgo compiler over a throwaway temp dir; the finally guarantees temp-dir cleanup, no Effect runtime in scope
try {
writeFileSync(path.join(dir, fileName), source);
const result = spawnSync(
process.execPath,
[
resolveTsgoShim(),
"--noEmit",
"--strict",
"--skipLibCheck",
"--target",
"es2022",
"--module",
"esnext",
"--pretty",
"false",
fileName,
],
{ cwd: dir, encoding: "utf8" },
);
return `${result.stdout ?? ""}\n${result.stderr ?? ""}`
.split("\n")
.map((line) => line.trim())
.filter((line) => ERROR_LINE.test(line));
Comment on lines +56 to +76

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Silent pass on spawn failure

spawnSync sets result.error when the process cannot be started (e.g., ENOENT from a missing tsgo binary, an OOM kill, or a signal termination) and leaves result.stdout / result.stderr as null. The ?? "" guards produce empty strings, the ERROR_LINE filter matches nothing, and the function returns [] — indistinguishable from a clean type-check. Any test relying on this helper will silently pass without the compiler ever running. A result.error (or a null result.status) check is needed to surface the failure.

} finally {
rmSync(dir, { recursive: true, force: true });
}
};
2 changes: 1 addition & 1 deletion packages/plugins/desktop-settings/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
}
},
"scripts": {
"build": "tsup",
"build": "tsup && (tsc --declaration --emitDeclarationOnly --outDir dist --rootDir src || true)",

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 || true silences all tsc declaration-emit errors

The || true makes the build script always succeed regardless of why tsc exits non-zero. If tsc encounters real type errors (not just the rootDir/TS6059 issue mentioned in the PR), the build completes silently with potentially incomplete or incorrect .d.ts files. A targeted exit-code filter would let the intended TS6059 class through while still propagating other failures.

Suggested change
"build": "tsup && (tsc --declaration --emitDeclarationOnly --outDir dist --rootDir src || true)",
"build": "tsup && (tsc --declaration --emitDeclarationOnly --outDir dist --rootDir src 2>&1 | grep -v 'error TS6059' || true)",

"test": "vitest run",
"typecheck": "tsgo --noEmit",
"typecheck:slow": "tsc --noEmit"
Expand Down
2 changes: 1 addition & 1 deletion packages/plugins/desktop-settings/tsup.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { defineConfig } from "tsup";
export default defineConfig({
entry: ["src/server.ts", "src/client.tsx"],
format: ["esm"],
dts: true,
dts: false,
clean: true,
sourcemap: true,
external: ["@executor-js/sdk", "react"],
Expand Down
26 changes: 26 additions & 0 deletions patches/tsup@8.5.1.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
diff --git a/dist/index.js b/dist/index.js
index eff27819d14d659a39c50e6cf51516e11648d20b..e95a8a1c2f3a6385690435bb64ade92add7a7526 100644
--- a/dist/index.js
+++ b/dist/index.js
@@ -1024,7 +1024,7 @@ var terserPlugin = ({
// src/tsc.ts


-var _typescript = require('typescript'); var _typescript2 = _interopRequireDefault(_typescript);
+var _typescript; try { _typescript = require('typescript'); } catch (e) { _typescript = {}; } var _typescript2 = _interopRequireDefault(_typescript);
var logger = _chunkVGC3FXLUjs.createLogger.call(void 0, );
var AliasPool = (_class = class {constructor() { _class.prototype.__init.call(this); }
__init() {this.seen = /* @__PURE__ */ new Set()}
diff --git a/dist/rollup.js b/dist/rollup.js
index e128b61b9558318b9f86dc11d72c31f09a8eb7db..84033d81096d1d9242c63c5de05c4b4af2a5c842 100644
--- a/dist/rollup.js
+++ b/dist/rollup.js
@@ -6465,7 +6465,7 @@ export { ${[...exportedNames].join(", ")} };
// src/rollup.ts
var _worker_threads = require('worker_threads');
var _path = require('path'); var _path2 = _interopRequireDefault(_path);
-var _typescript = require('typescript'); var _typescript2 = _interopRequireDefault(_typescript);
+var _typescript; try { _typescript = require('typescript'); } catch (e) { _typescript = {}; } var _typescript2 = _interopRequireDefault(_typescript);

// node_modules/.pnpm/@rollup+pluginutils@5.3.0_rollup@4.53.2/node_modules/@rollup/pluginutils/dist/es/index.js

Loading