File tree Expand file tree Collapse file tree
test/fixtures/typescript/cast-need-parentheses
babel-plugin-proposal-optional-chaining/test/fixtures/transparent-expr-wrappers/ts-as-in-conditional Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -90,6 +90,14 @@ const enum CheckParam {
9090 forOfHead = 1 << 5 ,
9191}
9292
93+ function isTSTypeExpression ( node : t . Node ) {
94+ return (
95+ isTSAsExpression ( node ) ||
96+ isTSSatisfiesExpression ( node ) ||
97+ isTSTypeAssertion ( node )
98+ ) ;
99+ }
100+
93101const isClassExtendsClause = (
94102 node : t . Node ,
95103 parent : t . Node ,
@@ -369,9 +377,7 @@ export function ConditionalExpression(
369377 isBinary ( parent ) ||
370378 isConditionalExpression ( parent , { test : node } ) ||
371379 isAwaitExpression ( parent ) ||
372- isTSTypeAssertion ( parent ) ||
373- isTSAsExpression ( parent ) ||
374- isTSSatisfiesExpression ( parent )
380+ isTSTypeExpression ( parent )
375381 ) {
376382 return true ;
377383 }
@@ -406,6 +412,7 @@ export function LogicalExpression(
406412 node : t . LogicalExpression ,
407413 parent : t . Node ,
408414) : boolean {
415+ if ( isTSTypeExpression ( parent ) ) return true ;
409416 switch ( node . operator ) {
410417 case "||" :
411418 if ( ! isLogicalExpression ( parent ) ) return false ;
Original file line number Diff line number Diff line change 11( < T > x).y;
22(x as T).y;
33x!.y;
4+
5+ (point1 ?? point2 as Point);
6+ (point1 ?? point2) as Point;
Original file line number Diff line number Diff line change 11( < T > x).y;
22(x as T).y;
3- x!.y;
3+ x!.y;
4+ point1 ?? (point2 as Point);
5+ ((point1 ?? point2) as Point);
Original file line number Diff line number Diff line change 11a => {
22 var _a$c ;
3- ( ( a !== null && a !== void 0 && a . b as any ) && ( _a$c = a . c ) !== null && _a$c !== void 0 && _a$c . d as any ) ? 0 : 1 ;
3+ ( ( ( ( a !== null && a !== void 0 && a . b ) as any ) && ( _a$c = a . c ) !== null && _a$c !== void 0 && _a$c . d ) as any ) ? 0 : 1 ;
44} ;
You can’t perform that action at this time.
0 commit comments