Skip to content
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

Give a better error message when an import isn't found but a namespace of the same name exists #10464

Open
DanielRosenwasser opened this issue Aug 21, 2016 · 2 comments
Labels
Bug A bug in TypeScript Domain: Error Messages The issue relates to error messaging Effort: Moderate Requires experience with the TypeScript codebase, but feasible. Harder than "Effort: Casual". Help Wanted You can do this
Milestone

Comments

@DanielRosenwasser
Copy link
Member

DanielRosenwasser commented Aug 21, 2016

See #10463.

foo.d.ts

declare module foo {
    // ...
}

bar.ts

import foo = require("foo");

"foo" won't be found, but if the compiler can resolve an identifier named foo to a namespace that uses the declare module syntax, we should probably give an error like

Cannot find module 'foo'.
  A legacy-style namespace with the same name was found.
    Try changing the declaration to use quotes (e.g. 'declare module "foo"').
@DanielRosenwasser DanielRosenwasser added Bug A bug in TypeScript Help Wanted You can do this Effort: Moderate Requires experience with the TypeScript codebase, but feasible. Harder than "Effort: Casual". Domain: Error Messages The issue relates to error messaging labels Aug 21, 2016
@RyanCavanaugh
Copy link
Member

RyanCavanaugh commented Aug 22, 2016

Somewhat skeptical that turning the namespace declaration into an external module declaration is the most likely fix. I feel like people making this error are more likely writing global code and thinking they need to do some incantation to access things across file boundaries

@DanielRosenwasser
Copy link
Member Author

I think as soon as you see an import, you can figure the user is trying to use modules, but I see what you're saying.

@mhegazy mhegazy added this to the Community milestone Sep 21, 2016
@RyanCavanaugh RyanCavanaugh modified the milestones: Community, Backlog Mar 7, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug A bug in TypeScript Domain: Error Messages The issue relates to error messaging Effort: Moderate Requires experience with the TypeScript codebase, but feasible. Harder than "Effort: Casual". Help Wanted You can do this
Projects
None yet
Development

No branches or pull requests

3 participants