-
Notifications
You must be signed in to change notification settings - Fork 13.2k
Closed
Labels
By DesignDeprecated - use "Working as Intended" or "Design Limitation" insteadDeprecated - use "Working as Intended" or "Design Limitation" instead
Description
Hello, is it intended behavior for this to happen:
//FILE 1
module Test {
var x : WebGLRenderingContext;
export class Test1 {
//Assume x is initialized
}
}//FILE 2
module Test {
export class Test2 {
//Assume member method clearColor() is called on x
//Error: Cannot find name 'x'
}
}which compiles to:
//FILE 1
var Test;
(function (Test) {
var x;
var Test1 = (function () {
function Test1() {
}
return Test1;
})();
Test.Test1 = Test1;
})(Test || (Test = {}));
//FILE 2
var Test;
(function (Test) {
var Test2 = (function () {
function Test2() {
}
return Test2;
})();
Test.Test2 = Test2;
})(Test || (Test = {}));Note that this is a module that takes place in two separate files. I am attempting to access a method of x from a file where x was not specifically declared, but it was declared for the module.
If you combine File 1 and File 2 to get something like this:
//FILE 1
module Test {
var x : WebGLRenderingContext;
export class Test1 {
//Assume x is initialized
}
export class Test2 {
//Assume member method clearColor() is called on x
//Works fine
}
}which compiles to:
//FILE 1
var Test;
(function (Test) {
var x;
var Test1 = (function () {
function Test1() {
}
return Test1;
})();
Test.Test1 = Test1;
var Test2 = (function () {
function Test2() {
}
return Test2;
})();
Test.Test2 = Test2;
})(Test || (Test = {}));everything works fine. The only solution I have found was to export the variable in the first file. However, the reason I'm not exporting it already is because I don't want the variable to visible outside the module.
Could someone explain why two modules in separate files wouldn't be merged?
Metadata
Metadata
Assignees
Labels
By DesignDeprecated - use "Working as Intended" or "Design Limitation" insteadDeprecated - use "Working as Intended" or "Design Limitation" instead