Skip to content
This repository was archived by the owner on Oct 12, 2022. It is now read-only.
This repository was archived by the owner on Oct 12, 2022. It is now read-only.

Document namespace workaround for typing import * as x #350

Open
@garthk

Description

@garthk

Writing Declaration Files under "Function as an Module " doesn't mention the namespace required for ES6 imports to work, as documented in microsoft/TypeScript#5073 and marked By Design by @mhegazy.

TL;DR: you need the namespace in the typing below, else tsc will error out when you import * from 'foo':

Module '"foo"' resolves to a non-module entity and cannot be imported using this construct

declare module "foo" {
  function foo(): void;
  namespace foo {} // required for ES6: import * from "foo";
  export = foo;
}

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions