-
Notifications
You must be signed in to change notification settings - Fork 71
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
type-checking doesn't work on type-only modules #298
Comments
Yep, looks like a bug -- rollup never processes |
This might be the root cause underlying #212 as well 🤔 (EDIT: It's related, but not quite the root cause. See my comment there for more details) Also thanks for providing a repro! |
@ezolenko from staring at the code for a while as well as the log, it looks like TS did find it (it's in If I'm understanding how Rollup works correctly, since it would be tree-shaken, it doesn't show up in the #212 may have a similar (but not same) cause, in that TS finds the |
EDIT: this isn't actually a duplicate of #7. While closely related, #7 is more specific to type-only imports when it comes to cache invalidation. See below for more details |
root cause analysis complete
Been looking into this issue on and off the past month (and even well before this issue), and think I've finally wrapped my head around this. Here's a sequence:
So this isn't actually due to Rollup's tree-shaking per se, type-only files are actually never part of Rollup's import tree at all (tree-shaking can impact this in other cases though, such as when there's an import in dead code). solving the issuesolving for
|
#345 should fix this specific issue as it relies on |
What happens and why it is wrong
When module contains only types (type,interface), and those types are being imported in other module, this plugin will omit those completely from type-checking which causes shipping invalid code to consumers.
🎬 Whole repro can be found here: https://stackblitz.com/edit/github-kgn16z-grsqrq?file=libs/test/rollup-config.js
yarn rollup:tsc
(uses this plugin with rollup) -> this will produce no Type errors 🚨 (Wrong)yarn tsc:check
(uses raw tsc) -> this will properly produce type errors ✅ (Correct, expected)Source Code
Versions
rollup.config.js
`rollup.config.js`:
tsconfig.json
`tsconfig.json`:
package.json
`package.json`:
plugin output with verbosity 4
plugin output with verbosity 3:
Related issues
#211
The text was updated successfully, but these errors were encountered: