Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

can't find constructor references of indirectly import #1561

Open
zxt5105515 opened this issue Jul 26, 2024 · 0 comments
Open

can't find constructor references of indirectly import #1561

zxt5105515 opened this issue Jul 26, 2024 · 0 comments

Comments

@zxt5105515
Copy link

i need to find all methods usage in a library testLib , so i search all modules and classes in testLib/index.d.ts ,then search all methods usage, everything works fine but the constructor usage can't be find .
i use a common.ts to wrap testLib's class , if i import class directly from testLib, constructor references works fine .
please help.

my testProject
--Typing
----testLib
------index.d.ts
--index.ts
--common.ts

index.d.ts

declare namespace Name1 {
  declare namespace Name2{
    class MyClassA{
       public fun1():void
       public constructor()        //can't find references 
    }
  }
}

common.ts

import MyClassA  = Name1.Name2.MyClassA
export {MyClassA}

index.ts

import { MyClassA} from "./common"
let a = new MyClassA()
a.fun1()

my morph project is simple ,

//setup project
//...
//get sourcefile from 'Typing/testLib/index.d.ts'
let sourceFile:SourceFile = ... 
//get MyClass class in sourceFile
let class:ClassDeclaration =  ...

//search refs
for (let fun of class.getMethods()) {
    let refs = fun.findReferences() // refs length is 1 ,and it's right ,ref by index.ts      
}

for (let fun of class.getConstructors()) {
    let refs = fun.findReferences()   //refs length is 0 ,can't find  constructor usage
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant