Microsoft/TypeScript

Strange "Cannot use namespace 'Foo' as a type" error with dummy `declare module "foo";` declaration

开放

#27,311 创建于 2018年9月24日

 (12 条评论) (19 个反应) (0 位负责人)TypeScript (13,395 个派生)batch import
BugDomain: Error MessagesHelp Wanted

仓库指标

星标
 (108,860 个星标)
PR 合并指标
 (PR 指标待抓取)

描述

Maybe this is a question, but it has come up multiple times on Stack Overflow (most recently here) without a good answer, so I'm asking it here.

TypeScript Version: master (03af107)

Search Terms: "cannot use namespace" "as a type" TS2709 "declare module"

Code

declare module "foo";

declare module "bar" {
    import { Foo } from "foo";
    let x: Foo;
}

Expected behavior: An error that makes sense, or no error?

Actual behavior: error TS2709: Cannot use namespace 'Foo' as a type.

Playground Link: link

Related Issues: None found

贡献者指南