-
Notifications
You must be signed in to change notification settings - Fork 12.6k
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
Separated internal module to a single function #4779
Comments
I know that I can write: module Main {
function F1() {
}
export function F2() {
F1();
}
} But it is not a good idea, because sometimes I have very big classes and functions. |
The problem is that it is not generally safe to merge module/namespace declarations like this. We would have to figure out if/when it's safe and only merge then (or does the user need to specify it?). We'd like also need #892. In any case, there is another suggestion already logged to track this idea but I can't find it at the moment. Someone wrote a node package that can perform the optimization for you but it is up to you to ensure the optimization is safe for your codebase. |
@danquirk Yes, user need to specify. I found that suggestion after I created this one. It was created 10 days ago #4652. You are right, there is an NPM package which will concatenate the output.. but IDE(VSCode, VS2015 or other) will message me an error(read P.S. of the issue). |
Thanks for finding that, I knew it was just the other day but search was failing me. I'm going to close this issue as a dupe, feel free to add your support/ideas to either of those suggestions. |
Why TS generates two functions, but not one?
We have one module separated between two files in TS, or in one file, but separated by other code. And we need to call F1 from F2. But do not need to cal F1 outside of
Main
module. Now we can write just like this:And it compiles to JS as two independent functions, so user can access F1 function:
But it seems to me that it will be better to concatenate the content of the modules with single name to one function. Like this JS output:
So there will be no need to create additional export members just to allow execute one members from the others inside one module.
p.s. Such code will fail:
The text was updated successfully, but these errors were encountered: