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 {
13
13
UNKNOWN_PATH
14
14
} from '../utils/PathTracker' ;
15
15
import { getRenderedLiteralValue } from '../utils/renderLiteralValue' ;
16
- import type NamespaceVariable from '../variables/NamespaceVariable' ;
16
+ import NamespaceVariable from '../variables/NamespaceVariable' ;
17
17
import ExpressionStatement from './ExpressionStatement' ;
18
18
import type { LiteralValue } from './Literal' ;
19
19
import type * as NodeType from './NodeType' ;
@@ -105,10 +105,8 @@ export default class BinaryExpression extends NodeBase implements DeoptimizableE
105
105
if ( typeof leftValue === 'symbol' ) return UnknownValue ;
106
106
107
107
// 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 ;
112
110
}
113
111
114
112
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