tsrx-typegen 0.3.1 → 0.4.0

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.
package/README.md CHANGED
@@ -150,6 +150,14 @@ the package and bare package imports are declared dependencies or peers. The com
150
150
  TypeScript consumer test for the module-resolution modes and public prop
151
151
  contracts your package supports.
152
152
 
153
+ The checker requires paired runtime and type exports. Pure type-only export
154
+ maps and mixed Node tooling exports without type entries need separate
155
+ package-specific validation.
156
+
157
+ ```sh
158
+ pnpm exec tsrx-typegen --pack-check
159
+ ```
160
+
153
161
  A target with `"emit": false` exists only to drive packed-package
154
162
  verification. Packages whose declarations are handwritten or produced by
155
163
  another tool declare one so `--pack-check` skips generation and freshness
@@ -1,11 +1,7 @@
1
1
  #!/usr/bin/env node
2
- // Prefer the emitted dist/ build (published tarballs); fall back to src/ so
3
- // in-repo typegen needs no build step (Node ≥22.18 strips types).
4
- import { existsSync } from 'node:fs'
5
-
6
- const dist = new URL('../dist/cli.js', import.meta.url)
7
- if (existsSync(dist)) {
8
- await import(dist.href)
9
- } else {
10
- await import(new URL('../src/cli.ts', import.meta.url).href)
11
- }
2
+ // Published installs live under node_modules, where Node refuses type
3
+ // stripping — run the emitted dist/. In-repo runs always execute src/ (Node
4
+ // ≥22.18 strips types): a stale, gitignored dist/ would otherwise run old code
5
+ // under turbo cache keys hashed from current source.
6
+ const entry = import.meta.url.includes('/node_modules/') ? '../dist/cli.js' : '../src/cli.ts'
7
+ await import(new URL(entry, import.meta.url).href)
@@ -178,7 +178,7 @@ function compilerExports(ts, program, file, cache = /* @__PURE__ */ new Map(), p
178
178
  if (symbol.flags & ts.SymbolFlags.Alias) try {
179
179
  resolved = checker.getAliasedSymbol(symbol);
180
180
  } catch {}
181
- if (resolved.flags & ts.SymbolFlags.Value) values.add(symbol.name);
181
+ if (!symbol.declarations?.some((declaration) => ts.isExportSpecifier(declaration) && (declaration.isTypeOnly || declaration.parent.parent.isTypeOnly)) && resolved.flags & ts.SymbolFlags.Value) values.add(symbol.name);
182
182
  }
183
183
  const typeOnly = /* @__PURE__ */ new Set();
184
184
  for (const statement of source.statements) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tsrx-typegen",
3
- "version": "0.3.1",
3
+ "version": "0.4.0",
4
4
  "description": "Generate consumer-ready TypeScript declarations for TSRX libraries",
5
5
  "keywords": [
6
6
  "build-tool",
package/src/pack-check.ts CHANGED
@@ -352,7 +352,15 @@ function compilerExports(
352
352
  } catch {}
353
353
  }
354
354
 
355
- if (resolved.flags & ts.SymbolFlags.Value) {
355
+ // Star barrels retain the originating alias declaration. An unresolved
356
+ // external type resolves to TypeScript's unknown symbol (which has value
357
+ // flags), so preserve an explicit type-only edge before using those flags.
358
+ const typeOnlyAlias = symbol.declarations?.some(
359
+ (declaration) =>
360
+ ts.isExportSpecifier(declaration) &&
361
+ (declaration.isTypeOnly || declaration.parent.parent.isTypeOnly),
362
+ )
363
+ if (!typeOnlyAlias && resolved.flags & ts.SymbolFlags.Value) {
356
364
  values.add(symbol.name)
357
365
  }
358
366
  }