File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -175,16 +175,18 @@ export function isStatementOrBlock(this: NodePath): boolean {
175175 */
176176
177177export function referencesImport (
178- this : NodePath < t . Expression > ,
178+ this : NodePath ,
179179 moduleSource : string ,
180180 importName : string ,
181181) : boolean {
182182 if ( ! this . isReferencedIdentifier ( ) ) {
183183 if (
184- ( this . isMemberExpression ( ) || this . isOptionalMemberExpression ( ) ) &&
185- ( this . node . computed
186- ? isStringLiteral ( this . node . property , { value : importName } )
187- : ( this . node . property as t . Identifier ) . name === importName )
184+ ( this . isJSXMemberExpression ( ) &&
185+ this . node . property . name === importName ) ||
186+ ( ( this . isMemberExpression ( ) || this . isOptionalMemberExpression ( ) ) &&
187+ ( this . node . computed
188+ ? isStringLiteral ( this . node . property , { value : importName } )
189+ : ( this . node . property as t . Identifier ) . name === importName ) )
188190 ) {
189191 const object = (
190192 this as NodePath < t . MemberExpression | t . OptionalMemberExpression >
Original file line number Diff line number Diff line change @@ -161,6 +161,14 @@ describe("path/introspection", function () {
161161 const reference = program . get ( "body.1.expression" ) ;
162162 expect ( reference . referencesImport ( "source" , "😅" ) ) . toBe ( true ) ;
163163 } ) ;
164+ it ( "accepts a named import via a namespace import jsx member expression" , function ( ) {
165+ const program = getPath ( `import * as ns from "source"; <ns.dep />;` , {
166+ sourceType : "module" ,
167+ plugins : [ "jsx" ] ,
168+ } ) ;
169+ const reference = program . get ( "body.1.expression.openingElement.name" ) ;
170+ expect ( reference . referencesImport ( "source" , "dep" ) ) . toBe ( true ) ;
171+ } ) ;
164172 it ( "rejects a named import from the wrong module" , function ( ) {
165173 const program = getPath ( `import { dep } from "wrong-source"; dep;` , {
166174 sourceType : "module" ,
You can’t perform that action at this time.
0 commit comments