TypeScript/tests/baselines/reference/enumPropertyAccess.js
2014-07-12 17:30:19 -07:00

30 lines
565 B
JavaScript

//// [enumPropertyAccess.ts]
enum Colors {
Red,
Green
}
var x = Colors.Red; // type of 'x' should be 'Colors'
var p = x.Green; // error
x.toFixed(); // ok
// Now with generics
function fill<B extends Colors>(f: B) {
f.Green; // error
f.toFixed(); // ok
}
//// [enumPropertyAccess.js]
var Colors;
(function (Colors) {
Colors[Colors["Red"] = 0] = "Red";
Colors[Colors["Green"] = 1] = "Green";
})(Colors || (Colors = {}));
var x = 0 /* Red */;
var p = x.Green;
x.toFixed();
function fill(f) {
f.Green;
f.toFixed();
}