@effected/tsconfig-json 0.3.1 → 0.3.2

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/README.md +41 -0
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -104,6 +104,47 @@ const compilerOptions = TsconfigLoaderSync.compilerOptions("./tsconfig.json", op
104
104
 
105
105
  `load` and `resolve` have the same synchronous forms. Failures are the async pipeline's own typed errors thrown as themselves — `TsconfigParseError`, `TsconfigExtendsError` or a `PlatformError` wrapping whatever your `readFile` threw — never a fiber-failure wrapper.
106
106
 
107
+ ## TypeScript 7 and the classic compiler API
108
+
109
+ TypeScript 7's native `tsc` ships a version-only stub as its `.` export — there is no JS compiler API behind it. A package that drives the typechecker as a library (`@typescript/vfs`, the language service, the Program API) can neither type against nor runtime-load a TypeScript 7 install, and the obvious fix of pinning the dev `typescript` back to 6 forfeits the native `tsc` and leaves toolchain peers on `^7` unmet. The recipe that keeps both starts here, because this package is what removes the compile-time half of the dependency.
110
+
111
+ 1. Type against the tsconfig JSON form, not the compiler. Public option types use `CompilerOptions.Type` — `{ target: "es2022" }`, strings all the way down — so nothing in `src` or the tests imports `typescript`, not even as a type. The dev `typescript` stays on 7, native `tsc --noEmit` still runs the typecheck, and the toolchain's `^7` peer stays satisfied.
112
+ 2. Convert at a single runtime seam. `TsEnumCodec.encodeCompilerOptions` maps the string form to the numeric enums a real compiler expects and returns `ProgrammaticCompilerOptions`, the shape a `ts.CompilerOptions`-typed API takes without a cast. Only that one call site knows a compiler exists.
113
+ 3. Alias a classic install for the test runtime, where the JS API is genuinely needed: a dev-only `"typescript-classic": "npm:typescript@^6.0.3"` plus a vitest `resolve.alias` mapping `typescript` to it. The consumer-facing peer stays an optional `^6` — runtime-only, for callers of the compiler-touching module.
114
+ 4. Pass `tsLibDirectory` explicitly when you drive `@typescript/vfs`. It locates `lib.*.d.ts` through `require.resolve("typescript")`, which under this setup resolves the TypeScript 7 install, and that install has no lib directory: the map comes back **empty**, silently, with no error to follow. Derive the directory from the module you actually loaded.
115
+
116
+ ```json
117
+ {
118
+ "devDependencies": {
119
+ "typescript-classic": "npm:typescript@^6.0.3"
120
+ }
121
+ }
122
+ ```
123
+
124
+ ```ts
125
+ import { defineConfig } from "vitest/config";
126
+
127
+ export default defineConfig({
128
+ resolve: { alias: { typescript: "typescript-classic" } },
129
+ });
130
+ ```
131
+
132
+ ```ts
133
+ import { dirname } from "node:path";
134
+ import { TsEnumCodec } from "@effected/tsconfig-json";
135
+ import { createDefaultMapFromNodeModules } from "@typescript/vfs";
136
+ import ts from "typescript";
137
+
138
+ const fsMap = createDefaultMapFromNodeModules(
139
+ TsEnumCodec.encodeCompilerOptions({ target: "es2023", lib: ["esnext"] }),
140
+ ts,
141
+ dirname(ts.sys.getExecutingFilePath()),
142
+ );
143
+
144
+ console.log(fsMap.size);
145
+ // the lib files the loaded compiler ships; drop the third argument and this is 0
146
+ ```
147
+
107
148
  ## Features
108
149
 
109
150
  - `TsconfigJson` / `TsconfigJsonFromString` — the document schema and its JSONC string codec. Comments and trailing commas are legal in every parse; there is no JSON-strict path.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@effected/tsconfig-json",
3
- "version": "0.3.1",
3
+ "version": "0.3.2",
4
4
  "private": false,
5
5
  "description": "Composable tsconfig.json handling for Effect: schemas, extends-chain resolution, and config discovery.",
6
6
  "keywords": [