Description
When I built my project in TS-Go I ended up getting thousands of errors. While I'm still working through some of them to make more reports, the ones that struck me as most obviously problematic is thousands of errors in .js
files in dependencies.
I decided to minimize my repo's code into something easier to investigate.
// index.ts
import "vitest/config";
import "simple-peer";
// package.json
{
"dependencies": {
"@types/simple-peer": "~9.11.1",
"@typescript/native-preview": "^7.0.0-dev.20250523.1",
"typescript": "^5.8.3",
"vite": "^6.3.5",
"vitest": "^3.0.5"
}
}
// tsconfig.json
{
"$schema": "https://json.schemastore.org/tsconfig.json",
"compilerOptions": {
"target": "ESNext",
"module": "NodeNext",
"noEmit": true,
"noUncheckedSideEffectImports": true, // Optional
"allowJs": true,
"checkJs": true
}
}
Here's that same code as a zip: dependency-js-errors.zip.
When npx tsc
is run there are 0 errors, when npx tsgo
is run this is the summary of the errors:
Found 321 errors in 4 files.
Errors Files
305 node_modules/chai/chai.js:13
8 node_modules/vitest/dist/chunks/reporters.d.C-cu31ET.d.ts:5
2 node_modules/vitest/dist/chunks/vite.d.iXCEVtFP.d.ts:1
6 node_modules/vitest/dist/config.d.ts:1
My original repo experienced many more errors due to stricter tsconfig rules but I suspect that fixing these errors will fix the JS errors in my repo.
I stopped my reduction scripts once they had reduced down to minimal code in my own repo but if you'd my to help reducing the dependencies as well I'd be happy to help.
Activity
LukeAbby commentedon May 24, 2025
BTW, I tried this PR against #930 and it did not fix the issue. @jakebailey was this something that was intended to be fixed in your PR?
jakebailey commentedon May 24, 2025
I wouldn't think so, given you have checkJs on and my PR would only fix errors when it's off.
jakebailey commentedon Jun 4, 2025
Things should have improved here, can you retest?
LukeAbby commentedon Jun 4, 2025
@jakebailey If I take that zip, update
tsgo
withnpm add -D @typescript/native-preview
, and then runnpx tsgo
I unfortunately get this panic:jakebailey commentedon Jun 13, 2025
I don't see the crash, but it does emit a bunch of errors:
jakebailey commentedon Jun 13, 2025
Oddly, this one chai file is added to the program in tsgo, but not in tsc.
jakebailey commentedon Jun 13, 2025
I feel like this must be a module resolution bug. I added some extra logging, and:
For some reason, we're resolving the import
chai
inside the package tochai.js
and then we include it.That or, it's just specifically that we're not excluding that in file loading? Need to cross check Strada.
sheetalkamat commentedon Jun 13, 2025
We have node modules depth to not add files after certain depth in node modules .. that part is bot ported yet ..
jakebailey commentedon Jun 13, 2025
I guess it could just be that. I was assuming that because this is a "real" project that the depth thing has nothing to do with it.
jakebailey commentedon Jun 13, 2025
Huh, no, I'm just wrong. The code really doesn't care, it's just that we set it to zero normally. I'll try and port that code quick.
jakebailey commentedon Jun 14, 2025
The concurrency makes this not simple, who would have guessed.
LukeAbby commentedon Jun 14, 2025
@jakebailey the version I installed that had the crash was
7.0.0-dev.20250604.1
(the latest available at the time). It looks like the crash was fixed in7.0.0-dev.20250606.1
and has stayed fixed since then.jakebailey commentedon Jun 14, 2025
@LukeAbby Can you try #1189 out? I believe it fixes your problem.
jakebailey commentedon Jun 14, 2025
Then again:
So, maybe not quite perfect yet (but seemingly still helps).
LukeAbby commentedon Jun 15, 2025
I can confirm I no longer get any suspicious JS file errors! It sounds like it might not work for someone else but for me it's perfect. I'll file another issue if I run into it again of course.
jakebailey commentedon Jun 15, 2025
Fixed the above discrepency in the PR: