-
Notifications
You must be signed in to change notification settings - Fork 198
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
QUESTION : resolve imports #48
Comments
I'm glad you like it! There's still a long way to go.... lots of work to do. Ah, that's pretty cool. I've often thought that generated documentation is a very useful application for using the typescript compiler. Note on remaining text... I did not re-read what I wrote here... just fired it off. Hopefully it helps as-is... Using Transformation APIAre you trying to change this when emitting the javascript code? If so, I believe probably the best thing to do to accomplish what you want to do would be to use the transformation api. Basically:
I'm not entirely sure how you would create the Using this Library (Not supported yet)This is actually a hard problem and I haven't included all the details. Probably the easiest thing to do would be to:
Anyway, sorry that's not all supported. I'm working on it though... Sidenote: I have written down the general idea of "reference paths" so it would basically give you a view of how something (like |
@dsherret |
Closing for now. Please feel free to reopen this if your question wasn't answered properly or if you need clarification on something. |
Hi David, Is there any news about the approach or syntax with the latest development of ts-simple-ast ? |
@vogloblinsky I think I misunderstood your original question. What's the expected output? Is it this? // module-b.ts
let toto = 5;
console.log(toto); If so, I believe that you just need to use That should be easy to do. |
Closing for now. Please let me know if this doesn't solve your question. |
No, you can leave closed, i manage to get things done. Thanks ! |
Indeed there are lots of scenarios. I was happy to find this discussion and thought I'd share what I came up with for the alias/renames, because it can happen both on import and export, in case someone finds it useful (maybe it can help to advance the API): const aliasedExportedSymbols = project.getSourceFiles()
.map(sourceFile => sourceFile.getExportDeclarations()
.map(exportDeclaration => exportDeclaration.getNamedExports())).flat().flat();
const importedSymbols = project.getSourceFiles()
.map(sourceFile => sourceFile.getImportDeclarations()
.map(importDeclaration => importDeclaration.getNamedImports())).flat().flat();
const aliasedImportedSymbols = importedSymbols
.filter(importedSymbol => importedSymbol.getAliasNode() !== undefined); These aren't tested fully, but with some toy examples it gives good results. |
Hi,
First, let' say 👍 about this library, very wonderful work !!
I am the maintainer of compodoc, a documentation tool for Angular applications. https://github.com/compodoc/compodoc
I need for some use-case to support dynamic imports of different things.
Would be nice if during AST parsing with TypeScript, if i could edit the AST node of toto variable to inject VERSION instead of just having a reference.
Did you know how can i achieve this with your lib or just with TypeScript compiler APIs ?
This blog http://blog.scottlogic.com/2017/05/02/typescript-compiler-api-revisited.html, chapter "TRANSFORMING THE AST" helps a little
Thanks
The text was updated successfully, but these errors were encountered: