TypeScript/tests/baselines/reference/castExpressionParentheses.js
2014-07-14 14:26:19 -07:00

69 lines
1,014 B
JavaScript

//// [castExpressionParentheses.ts]
declare var a;
// parentheses should be omitted
// literals
(<any>{a:0});
(<any>[1,3,]);
(<any>"string");
(<any>23.0);
(<any>/regexp/g);
(<any>false);
(<any>true);
(<any>null);
// names and dotted names
(<any>this);
(<any>this.x);
(<any>(<any>a).x);
(<any><any>a);
(<any>a[0]);
(<any>a.b["0"]);
(<any>a()).x;
declare var A;
// should keep the parentheses in emit
(<any>new A).foo;
(<any>typeof A).x;
(<any>-A).x;
new (<any>A());
(<Tany>()=> {})();
(<any>function foo() { })();
(<any><number><any>-A).x;
// nested cast, should keep one pair of parenthese
(<any><number>(<any>-A)).x;
// nested parenthesized expression, should keep one pair of parenthese
(<any>(A))
//// [castExpressionParentheses.js]
{ a: 0 };
[1, 3, ];
"string";
23.0;
/regexp/g;
false;
true;
null;
this;
this.x;
a.x;
a;
a[0];
a.b["0"];
a().x;
(new A).foo;
(typeof A).x;
(-A).x;
new (A());
(function () {
})();
(function foo() {
})();
(-A).x;
(-A).x;
(A);