Skip to content

Members of re-exported namespace can be used as values but not types #35165

Closed
@ultimatelostcause

Description

@ultimatelostcause

TypeScript Version: 3.8.0-dev.20191116

Search Terms:

  • export namespace
  • export merged namespace
  • export namespace type

Code

a.ts:

export namespace Foo {
   export class Bar {}
}

b.ts:

import {Foo as FooImpl} from './a.js'
export namespace Baz {
   export const Foo = FooImpl
}

Expected behavior:

import {Baz} from './b.js'
let x: Baz.Foo.Bar      // should compile without error

Actual behavior:

import {Baz} from './b.js'
let x: Baz.Foo.Bar      // Error: Namespace '".../b".Baz' has no exported member 'Foo'.
let y = new Baz.Foo.Bar // Ok

Playground Link:
I am unsure how to use TypeScript Playground to import custom modules.

Related Issues:

Metadata

Metadata

Assignees

No one assigned

    Labels

    QuestionAn issue which isn't directly actionable in code

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions