Skip to content
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

Typescript namespaces support #659

Open
pushkine opened this issue Oct 18, 2021 · 0 comments
Open

Typescript namespaces support #659

pushkine opened this issue Oct 18, 2021 · 0 comments

Comments

@pushkine
Copy link
Contributor

pushkine commented Oct 18, 2021

Hey I absolutely adore sucrase, thank you so much for building it!~

It's been mentioned before on #465 and #641, sucrase doesn't handle namespaces

I love namespaces and use them a lot, they're basically glorified objects and their output is very similar to enums.

I'd love to see them supported in sucrase, otherwise I think the readme really should mention that they're stripped from the output. Note that in runtime it shows up as "cannot access x in undefined" which is usually a sign of cyclical dependency

Input

export namespace foo {
	export function bar() {}
}
foo.bar();

Typescript output

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

Sucrase output

"use strict";


foo.bar();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant