File tree Expand file tree Collapse file tree 4 files changed +16
-5
lines changed
test/form/samples/external-namespace-optimzation-in-operator Expand file tree Collapse file tree 4 files changed +16
-5
lines changed Original file line number Diff line number Diff line change @@ -13,7 +13,7 @@ import {
1313 UNKNOWN_PATH
1414} from '../utils/PathTracker' ;
1515import { getRenderedLiteralValue } from '../utils/renderLiteralValue' ;
16- import type NamespaceVariable from '../variables/NamespaceVariable' ;
16+ import NamespaceVariable from '../variables/NamespaceVariable' ;
1717import ExpressionStatement from './ExpressionStatement' ;
1818import type { LiteralValue } from './Literal' ;
1919import type * as NodeType from './NodeType' ;
@@ -105,10 +105,8 @@ export default class BinaryExpression extends NodeBase implements DeoptimizableE
105105 if ( typeof leftValue === 'symbol' ) return UnknownValue ;
106106
107107 // Optimize `'export' in namespace`
108- if ( this . operator === 'in' && this . right . variable ?. isNamespace ) {
109- return (
110- ( this . right . variable as NamespaceVariable ) . context . traceExport ( String ( leftValue ) ) [ 0 ] != null
111- ) ;
108+ if ( this . operator === 'in' && this . right . variable instanceof NamespaceVariable ) {
109+ return this . right . variable . context . traceExport ( String ( leftValue ) ) [ 0 ] != null ;
112110 }
113111
114112 const rightValue = this . right . getLiteralValueAtPath ( EMPTY_PATH , recursionTracker , origin ) ;
Original file line number Diff line number Diff line change 1+ module . exports = {
2+ description : 'disables optimization for external namespace when using the in operator' ,
3+ options : {
4+ external : [ 'node:crypto' ]
5+ }
6+ } ;
Original file line number Diff line number Diff line change 1+ import * as nc from 'node:crypto' ;
2+
3+ const crypto = 'webcrypto' in nc ;
4+
5+ export { crypto } ;
Original file line number Diff line number Diff line change 1+ import * as nc from 'node:crypto' ;
2+ export const crypto = 'webcrypto' in nc ;
You can’t perform that action at this time.
0 commit comments