Import behavior mismatch from typescript 5 (bwip-js)
I'm getting an issue where tsgo doesn't recognize an import that is working with normal tsc.
relevant versions:
{
"dependencies": {
"@typescript/native-preview": "^7.0.0-dev.20250529.1",
"bwip-js": "^4.5.1",
"typescript": "^5.8.3"
}
}
To reproduce:
git clone https://github.com/ryanrasti/tsgo-import-mismatch-repro
cd tsgo-import-mismatch-repro
npm i
./node_modules/.bin/tsc # works fine
./node_modules/.bin/tsgo # get error "main.ts:1:23 - error TS2307: Cannot find module 'bwip-js' or its corresponding type declarations."
I don't understand what's causing the issue, but if you add "include": ["node_modules"] to your tsconfig it'll work under tsgo
Related: https://github.com/microsoft/typescript-go/issues/982
Related: #982
Nice that seems to work for this example, but it has some side-effects -- e.g., now I run into an issue where I can't include graphql because node_modules/graphql/NotSupportedTSVersion.d.ts gets imported (underlying issue is that it seems that for a package.json in node_modules, typesVersions is no longer respected)
Can you please file a new issue for your separate issue?
Can you please file a new issue for your separate issue?
I didn't test if that is truly a separate issue (i.e., a mismatch between tsc and tsgo) -- I was just commenting that the proposed workaround has side-effects that make it not workable for me.
Sorry, did not notice that you were the original issue filer. Adding that kind of include is definitely not an intended fix.
The problem here is that you have "moduleResolution": "Node" set, which implies module=commonjs, which then all together breaks things. This setup isn't supported by tsgo (and is not recommended in general).
If you instead change to nodenext resolution, your code compiles correctly.
See also: https://www.typescriptlang.org/docs/handbook/modules/guides/choosing-compiler-options.html