Skip to content

Namespace elements cannot export without declaration #5220

Open

Description

es6 modules can export module elements without declaration.

import foo from 'foo';
export {foo}

Namespaces are not.

import foo from 'foo';
namespace NS {
  export {foo} // not support syntax
  export var foo = foo; // invalid

  var bar = foo;
  export var foo = bar; // too redundant
}

Namespaces should support non-declaration export.

related: #5175

Activity

  1. RyanCavanaugh commented on Oct 12, 2015

    @RyanCavanaugh
    Member

    What should the emit for this look like?

  2. falsandtru commented on Oct 12, 2015

    @falsandtru
    ContributorAuthor

    I want this syntax and emit compatible with es6 modules.

    namespace NS {
      export {foo}
    }
    var NS;
    (function (NS) {
        NS.foo = foo;
    })(NS || (NS = {}));
  3. falsandtru commented on Oct 26, 2015

    @falsandtru
    ContributorAuthor

    use case

    export default A
    
    const Package = {
      Msg,
      Proxy: Proxy, // tslint bug. https://github.com/palantir/tslint/issues/684
      Tick: Tick
    };
    
    function A<T>() {
      return new ArchStream<T>();
    }
    namespace A {
      export const Msg = Package.Msg; // => export {Msg}
      export const Proxy = Package.Proxy; // => export {Proxy}
      export const Tick = Package.Tick; // => export {Tick}
    }
  4. jeffryang24 commented on Dec 28, 2018

    @jeffryang24

    I have the same problem like above:

    export namespace HomePage {
      export namespace Action {
        export namespace ActionTypes {
          export const OPEN_API_REQUEST = '@@homePage/OPEN_API_REQUEST'; --> this is invalid. :(
        }
      }
    }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    In DiscussionNot yet reached consensusSuggestionAn idea for TypeScript

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions