Skip to content

Instantly share code, notes, and snippets.

@DmitrySoshnikov
Created March 24, 2011 18:00
Show Gist options
  • Save DmitrySoshnikov/885534 to your computer and use it in GitHub Desktop.
Save DmitrySoshnikov/885534 to your computer and use it in GitHub Desktop.
Harmony modules import
/**
* Test for module imports
* Tested in Narcissus
* by Dmitry Soshnikov
*/
module M {
export var x = 10;
export var y = 20;
}
import M.x;
var y = M.y;
console.dir(Object.getOwnPropertyDescriptor(this, "x"));
// Result for "x"
//
// {
// [[Class]]: "Object",
// get: function,
// set: null,
// enumerable: true,
// configurable: true
// }
console.dir(Object.getOwnPropertyDescriptor(this, "y"));
// Result for "x"
//
// {
// [[Class]]: "Object",
// value: 20,
// writable: true,
// enumerable: true,
// configurable: true
// }
console.log(x); // 10
console.log(y); // 20
y = 100; // ok
x = 200; // SyntaxError: assignment to imported variable
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment