Skip to content

import for side effects only does not check path #27289

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

Closed
poseidonCore opened this issue Sep 23, 2018 · 2 comments
Closed

import for side effects only does not check path #27289

poseidonCore opened this issue Sep 23, 2018 · 2 comments
Labels
Duplicate An existing issue was already created

Comments

@poseidonCore
Copy link

poseidonCore commented Sep 23, 2018

TypeScript Version: 3.1.0 [TS Playground 23 SEP 2018]
When using import for side effects only, the path does not seem to be checked.

Using import for side effects is useful in extending base classes and preparing an environment and should be checked in the same way as normal import statements.

Search Terms:
import for side effects only
bare import
unnamed import
missing file

Code

import * as x from "./someMissingFile";
/* <<<<< ERROR
Cannot find module './someMissingFile'.
ERROR >>>>> */

import "./someMissingFile";

Expected behavior:
Both should show the same error.

Actual behavior:
Only the first will validate the path, in either Intellisense or TS compilation.

Playground Link: TS Playground

Related Issues:

@RyanCavanaugh RyanCavanaugh added Working as Intended The behavior described is the intended behavior; this is not a bug Duplicate An existing issue was already created and removed Working as Intended The behavior described is the intended behavior; this is not a bug labels Sep 24, 2018
@RyanCavanaugh
Copy link
Member

See #20576, #20767, #20534, #23961

@poseidonCore
Copy link
Author

All of these references demonstrate the conflicting and frustrating nature of this issue. If you are not planning to fix this shortcoming, then you should accept it as a language feature and document it ... at least as a warning ...

A few lines under the heading "Import a module for side-effects only" would have avoided many of these duplicate issues:

https://www.typescriptlang.org/docs/handbook/modules.html

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Duplicate An existing issue was already created
Projects
None yet
Development

No branches or pull requests

2 participants