Skip to content
Merged
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
3 changes: 3 additions & 0 deletions .changeset/typescript-7-compatibility-lane.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
---

---
25 changes: 25 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,31 @@ understands imports, re-exports, and dynamic imports, and enforces:
The checker has executable fixture tests and runs as part of `pnpm check`. Add
new rules only with a failing fixture that demonstrates the boundary.

## TypeScript compatibility

The repository toolchain uses TypeScript 6. TypeDoc, tstyche, and the
repository scripts load its JavaScript compiler API, so the root `typescript`
dependency stays on 6.x.

`pnpm check` also verifies the native TypeScript 7 compiler. The private
`tooling/typescript-7` workspace package pins it in its own `node_modules`, so
its `tsc` binary never replaces the TypeScript 6 `tsc` used by the root and the
publishable packages:

- `pnpm typecheck:ts7` type-checks every package project and
`tsconfig.tests.json` without emitting. Run it after `pnpm typecheck` or
`pnpm build`, because package references resolve to the TypeScript 6
declaration output.
- `pnpm test:consumer` compiles the packed consumer fixture with TypeScript 6
and then with TypeScript 7. Set `TSGO_BIN` to an executable native compiler to
check another TypeScript 7 build.

Type tests run only with TypeScript 6: tstyche 7.2 selects targets from
TypeScript 5.4 up to, but not including, 7.0, because TypeScript 7 does not
provide the in-process compiler API that tstyche uses. TypeScript 7 still
compiles the public types through the package projects and the runtime tests,
but type assertions are evaluated only with TypeScript 6.

## API reference data

`pnpm docs:api` generates an Effect-compatible TypeDoc dataset under
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"check:architecture": "node --test scripts/check-architecture.test.mjs && node scripts/check-architecture.mjs packages/effect-machine && node scripts/check-devtools-architecture.mjs packages/devtools",
"check:ci": "node --test scripts/ci-changes.test.mjs scripts/effect-compatibility.test.mjs scripts/invoke-autocomplete.test.mjs scripts/release-contract.test.mjs scripts/runtime-performance-compatibility.test.mjs scripts/runtime-performance-regression.test.mjs",
"typecheck": "pnpm --recursive --filter \"./packages/**\" run check && tsc -p tsconfig.tests.json",
"typecheck:ts7": "pnpm --dir tooling/typescript-7 run typecheck",
"perf:types": "pnpm build && node scripts/type-performance.mjs",
"perf:runtime": "pnpm build && node --expose-gc scripts/runtime-performance.mjs",
"format": "dprint fmt",
Expand All @@ -28,7 +29,7 @@
"react:pack-check": "node scripts/react-pack-check.mjs",
"devtools:pack-check": "node scripts/devtools-pack-check.mjs",
"oxlint-plugin:pack-check": "node scripts/oxlint-plugin-pack-check.mjs",
"check": "pnpm format:check && pnpm check:architecture && pnpm check:ci && pnpm docs:api:check && pnpm docs:site:check && pnpm typecheck && pnpm build && pnpm test && pnpm test:types && pnpm test:consumer && pnpm pack:check && pnpm react:pack-check && pnpm devtools:pack-check && pnpm oxlint-plugin:pack-check",
"check": "pnpm format:check && pnpm check:architecture && pnpm check:ci && pnpm docs:api:check && pnpm docs:site:check && pnpm typecheck && pnpm typecheck:ts7 && pnpm build && pnpm test && pnpm test:types && pnpm test:consumer && pnpm pack:check && pnpm react:pack-check && pnpm devtools:pack-check && pnpm oxlint-plugin:pack-check",
"changeset": "changeset",
"version-packages": "changeset version && dprint fmt",
"release": "pnpm build && changeset publish"
Expand Down
6 changes: 3 additions & 3 deletions packages/effect-machine/test/machine/Machine.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ const sendAndWaitForSnapshot = <State, Event, Error, Output>(
const assertStateSnapshot = <Path extends string, Value>(
actual:
| Machine.Machine.AtomicSnapshot<Path, Value>
| Machine.Machine.CompoundSnapshot<"", undefined, Machine.Machine.AtomicSnapshot<Path, Value>>,
| Machine.Machine.CompoundSnapshot<"", undefined, NoInfer<Machine.Machine.AtomicSnapshot<Path, Value>>>,
path: Path,
value: Value
) => {
Expand All @@ -47,7 +47,7 @@ const assertStateSnapshot = <Path extends string, Value>(
const assertCompoundStateSnapshot = <Path extends string, Value, Child>(
actual:
| Machine.Machine.CompoundSnapshot<Path, Value, Child>
| Machine.Machine.CompoundSnapshot<"", undefined, Machine.Machine.CompoundSnapshot<Path, Value, Child>>,
| Machine.Machine.CompoundSnapshot<"", undefined, NoInfer<Machine.Machine.CompoundSnapshot<Path, Value, Child>>>,
path: Path,
value: Value,
state: Child
Expand All @@ -63,7 +63,7 @@ const assertCompoundStateSnapshot = <Path extends string, Value, Child>(
const assertParallelStateSnapshot = <Path extends string, Value, States>(
actual:
| Machine.Machine.ParallelSnapshot<Path, Value, States>
| Machine.Machine.CompoundSnapshot<"", undefined, Machine.Machine.ParallelSnapshot<Path, Value, States>>,
| Machine.Machine.CompoundSnapshot<"", undefined, NoInfer<Machine.Machine.ParallelSnapshot<Path, Value, States>>>,
path: Path,
value: Value,
states: States
Expand Down
214 changes: 214 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions pnpm-workspace.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
packages:
- "packages/*"
- "tooling/*"

overrides:
effect: 4.0.0
Expand Down
16 changes: 15 additions & 1 deletion scripts/test-consumer.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,26 @@ try {
[join(repositoryRoot, "node_modules", "typescript", "bin", "tsc"), "-p", join(consumer, "tsconfig.json")],
{ cwd: consumer }
)
// The consumer must also compile with the native TypeScript 7 compiler pinned
// by tooling/typescript-7. TSGO_BIN selects another native compiler binary.
if (process.env.TSGO_BIN !== undefined) {
run(process.env.TSGO_BIN, ["-p", join(consumer, "tsconfig.json")], { cwd: consumer })
} else {
run(
process.execPath,
[
join(repositoryRoot, "tooling", "typescript-7", "node_modules", "typescript", "bin", "tsc"),
"-p",
join(consumer, "tsconfig.json")
],
{ cwd: consumer }
)
}
run(process.execPath, [join(consumer, "runtime.mjs")], { cwd: consumer })

console.log("packed root, reactivity, cluster, and testing entrypoints passed strict consumer validation")
console.log(
"packed root, reactivity, cluster, and testing entrypoints passed strict consumer validation with TypeScript 6 and 7"
)
} finally {
await rm(destination, { recursive: true, force: true })
}
12 changes: 12 additions & 0 deletions tooling/typescript-7/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"name": "@typeonce/effect-machine-typescript-7",
"private": true,
"type": "module",
"description": "Pins the native TypeScript 7 compiler for the compatibility lane without replacing the TypeScript 6 toolchain.",
"scripts": {
"typecheck": "tsc -p ../../packages/effect-machine/tsconfig.json --noEmit && tsc -p ../../packages/effect-machine-react/tsconfig.json --noEmit && tsc -p ../../packages/oxlint-plugin/tsconfig.json --noEmit && tsc -p ../../packages/devtools/tsconfig.json && tsc -p ../../tsconfig.tests.json"
},
"devDependencies": {
"typescript": "7.0.2"
}
}
Loading