-
Notifications
You must be signed in to change notification settings - Fork 12.8k
No error for anonymous import that doesn't exist #28032
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
Comments
Duplicate of #27289 |
Figures. I never pick the right search terms... |
I checked into the other issues, it seems this is intentional behavior for backwards compatibility. I definitely understand that; that said, I’m a big refactor-fiend and this bit me after deleting a side-effect-only file from the project (I sometimes use these for polyfills), so if there could be a flag to optionally make this an error, it would be great to have. 😃 |
I'm planning to write a lint rule to do this check as long as the compiler doesn't make it an error: fimbullinter/wotan#426 |
This issue has been marked as a duplicate and has seen no activity in the last day. It has been closed for automatic house-keeping purposes. |
No compile-time error is produced for
import 'nonexistent_filename'
. An error is produced for nonexistent named imports (e.g.import X from './notExist.js'
), but for anonymous imports (when simply importing for side effects) no error is produced if the file doesn't exist, the import is emitted as-is, and the code fails at runtime.TypeScript Version: 3.2.0-dev.20181020
Search Terms: anonymous import no error
Code
Expected behavior:
2 errors should be produced:
./doesnt-exist-1.js
./doesnt-exist-2.js
Actual behavior:
Only 1 error is produced:
./doesnt-exist-1.js
Playground Link:
http://www.typescriptlang.org/play/#src=import%20foo%20from%20'.%2Fdoesnt-exist-1.js'%3B%0D%0Aimport%20'.%2Fdoesnt-exist-2.js'%3B%0D%0A
Related Issues:
Couldn't find any.
The text was updated successfully, but these errors were encountered: