Skip to content

Exposing local types in an ambient module's declare module failsΒ #63105

@hgl

Description

@hgl

πŸ”Ž Search Terms

ambient module, import

πŸ•— Version & Regression Information

  • This is the behavior in every version I tried, and I reviewed the FAQ for entries about Common "Bugs" That Aren't Bugs

⏯ Playground Link

No response

πŸ’» Code

// local.ts
export interface Foo {
  name: string
}
// ambient.d.ts
declare module "foo" {
  import type { Foo } from "./local.ts";

  export type { Foo };
  const foo: Foo;
  export default foo;
}
// foo.ts
import foo from "foo";

foo.name

πŸ™ Actual behavior

foo.name is of type any

πŸ™‚ Expected behavior

foo.name is of type string

Additional information about the issue

If I add export {}; to ambient.d.ts then it works, but I'm not trying to augment foo's type, it feels wrong.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions