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 +8 -0
- package/bin/tsrx-typegen.mjs +6 -10
- package/dist/pack-check.js +1 -1
- package/package.json +1 -1
- package/src/pack-check.ts +9 -1
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
|
package/bin/tsrx-typegen.mjs
CHANGED
|
@@ -1,11 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
//
|
|
3
|
-
//
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
const
|
|
7
|
-
|
|
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)
|
package/dist/pack-check.js
CHANGED
|
@@ -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
package/src/pack-check.ts
CHANGED
|
@@ -352,7 +352,15 @@ function compilerExports(
|
|
|
352
352
|
} catch {}
|
|
353
353
|
}
|
|
354
354
|
|
|
355
|
-
|
|
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
|
}
|