Microsoft/TypeScript

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

Open

#27 311 ouverte le 24 sept. 2018

Voir sur GitHub
 (12 commentaires) (19 réactions) (0 assignés)TypeScript (6 726 forks)batch import
BugDomain: Error MessagesHelp Wanted

Métriques du dépôt

Stars
 (48 455 stars)
Métriques de merge PR
 (Merge moyen 6j 17h) (9 PRs mergées en 30 j)

Description

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

Guide contributeur