镜像站点 · 本页由第三方 GitHub 只读镜像提供,非 GitHub 官方站点,不接受任何登录或凭据输入。前往 github.com
Skip to content

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

Description

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"').

Activity

  1. RyanCavanaugh commented on Aug 22, 2016

    @RyanCavanaugh
    Member

    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

  2. DanielRosenwasser commented on Aug 24, 2016

    @DanielRosenwasser
    MemberAuthor

    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.

  3. added this to the milestone on Sep 21, 2016
  4. RyanCavanaugh commented on Aug 25, 2026

    @RyanCavanaugh
    Member

    I don't think we need to do this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugA bug in TypeScriptDomain: Error MessagesThe issue relates to error messagingEffort: ModerateRequires experience with the TypeScript codebase, but feasible. Harder than "Effort: Casual".Help WantedYou can do this

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions