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
Description
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;
}