Commit df1cad3
committed
fix(core): drop unique-symbol brand on LocalsKey to fix dual-package builds
LocalsKey<T> was branded with a module-level `declare const __local: unique
symbol`. tshy emits separate .d.ts files for the ESM and CJS outputs, and
each gets its own `declare const __local: unique symbol` — TypeScript
treats every such declaration as a nominally distinct type.
Under certain pnpm hoisting layouts a single TypeScript compilation can
resolve LocalsKey from both the ESM source path and the CJS dist path
within the same call site. With unique-symbol brands the two variants are
structurally incompatible — TS rejects passing one to a function that
expects the other, with a misleading 'Property [__local] is missing' error.
Replace the symbol brand with an optional phantom value-type field. T is
still carried at the type level, the runtime shape is unchanged, and the
ESM and CJS .d.ts outputs are now identical.1 parent 15b7cde commit df1cad3
3 files changed
Lines changed: 25 additions & 8 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
8 | | - | |
| 8 | + | |
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
| |||
23 | 23 | | |
24 | 24 | | |
25 | 25 | | |
26 | | - | |
| 26 | + | |
27 | 27 | | |
28 | 28 | | |
29 | 29 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
2 | | - | |
3 | | - | |
4 | | - | |
5 | | - | |
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
6 | 16 | | |
7 | | - | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
8 | 20 | | |
9 | 21 | | |
10 | 22 | | |
| |||
0 commit comments