Skip to content

Namespace elements cannot export without declaration #5220

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
falsandtru opened this issue Oct 12, 2015 · 4 comments
Open

Namespace elements cannot export without declaration #5220

falsandtru opened this issue Oct 12, 2015 · 4 comments
Labels
In Discussion Not yet reached consensus Suggestion An idea for TypeScript

Comments

@falsandtru
Copy link
Contributor

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

@RyanCavanaugh
Copy link
Member

What should the emit for this look like?

@falsandtru
Copy link
Contributor Author

I want this syntax and emit compatible with es6 modules.

namespace NS {
  export {foo}
}
var NS;
(function (NS) {
    NS.foo = foo;
})(NS || (NS = {}));

@RyanCavanaugh RyanCavanaugh added Suggestion An idea for TypeScript In Discussion Not yet reached consensus labels Oct 12, 2015
@falsandtru
Copy link
Contributor Author

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

@jeffryang24
Copy link

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
Labels
In Discussion Not yet reached consensus Suggestion An idea for TypeScript
Projects
None yet
Development

No branches or pull requests

3 participants