Latest Results
fix(react-compiler): move index.ts/binding.js to package root
Reported by an automated reviewer: the previous layout (index.ts under
src/, binding.js/binding.d.ts also under src/, tsc's rootDir "./src" +
outDir "./") had `tsc -d` (running before `napi build` in build:dev,
same order as CI) generate its OWN weak, type-inferred root
binding.d.ts from src/binding.js (a plain JS file with no real type
annotations -- roughly `export = nativeBinding; declare let
nativeBinding: any`), since tsc treats already-existing .d.ts files as
ambient declarations it never copies to outDir, and only emits
declarations for .js/.ts source files it actually compiles. napi
build's own --dts flag only ever wrote the real, richly-typed
declarations to src/binding.d.ts, never to the root file that actually
ships. So `export type { Diagnostic, ... } from './binding'` and
`lint`/`lintSync`'s `binding.Diagnostic[]` return types resolved fine
while developing (tsc checks src/index.ts against its real,
correctly-located sibling src/binding.d.ts) but were broken for any
real downstream consumer of the published package, who only gets the
root-level files. Confirmed by simulating a consumer against only the
final built root/index.d.ts + root/binding.d.ts (no access to a src/
directory): `Cannot find module '../binding'` before this fix, clean
after.
@swc/core avoids this because its binding.js/binding.d.ts live at the
package root already, not under src/ -- an initial attempt to copy
that exact pattern here (keep index.ts under src/, use a type-only
`typeof import("../binding")` + separate runtime `require("./binding")`
split, matching @swc/core's own src/index.ts) turned out to have the
same latent bug: tsc emits the *literal* import-specifier text into
the compiled .d.ts without rewriting it for the new location, so
`../binding` ends up wrong in the emitted root index.d.ts too, once a
public signature (unlike @swc/core's internal-only use of that
pattern) actually needs to resolve it. Verified this by re-running the
same consumer simulation against that version -- still broken.
The actual fix: index.ts now lives at the package root too. It was the
only real source file under src/ (binding.js/binding.d.ts are napi
build's output, not authored TS/JS) once those moved out for the same
reason, so the src/ subdirectory no longer serves any purpose --
having rootDir/outDir differ was the entire source of the bug, and
with only one file, there's no reason to keep that split. `./binding`
is now unambiguously correct everywhere: same directory, before and
after compilation, for the source file, the compiled JS's require
call, and the emitted .d.ts's import specifier alike. Re-verified the
consumer simulation passes clean, and the runtime test suite
(tests/lint.test.cjs) still passes 4/4 against the new layout.
@swc/minifier has the identical structural bug (binding.js/d.ts under
src/, minifySync/minify return binding.TransformOutput) and is
already shipping it in production -- confirmed separately, left as a
distinct out-of-scope issue for this PR.imjordanxd:feat/react-compiler-lint-diagnostics Latest Branches
0%
imjordanxd:feat/react-compiler-lint-diagnostics 0%
hardfist:codex/remove-vergen-sccache +2%
kdy1/nodejs-wasm-typescript-api © 2026 CodSpeed Technology