-
Notifications
You must be signed in to change notification settings - Fork 12.6k
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
Comments for call expression arguments are not preserved in output #3844
Comments
@NickHeiner Nick, if you use this form if so, then this would be the recommended way to solve this problem. It's already the design of the .ts compiler (modulo bugs) that If angular only accepts |
According to the code of the ngAnnotate, it should work I think function inspectComments(ctx) {
const comments = ctx.comments;
for (let i = 0; i < comments.length; i++) {
const comment = comments[i];
const yesPos = comment.value.indexOf("@ngInject");
const noPos = (yesPos === -1 ? comment.value.indexOf("@ngNoInject") : -1);
if (yesPos === -1 && noPos === -1) {
continue;
}
const target = ctx.lut.findNodeFromPos(comment.range[1]);
if (!target) {
continue;
}
addSuspect(target, ctx, noPos >= 0);
}
} @mhegazy : If it failed, you can maybe use the other syntax, by using the '@ngInject" string |
@Gillespie59 Thanks! If that's the case, i think the appropriate solution is for people to annotate their If anyone sees a case where we are not preserving |
@Gillespie59 let us know whether it is the case the angular respect Edited: I miss this part |
This is a result of we don't preserve comment in the call expression. In following scenario, we didn't emit comment as well function foo(x: any){}
foo(/*lol*/ 10); |
I have a similar situation where comments are not preserved when defining a function on an object literal. resolve: {
id: /*! @ngInject */ (details: FooDetail) => details.id
} |
Any time that we don't preserve a |
@CyrusNajmabadi @mthamil I believe the root of this issue is that we do not preserve comment at all when the comment is not lead by new line regardless of the For example: var x = 10;
/*comment*/ () => { }, /*comment1*/ () => { } /comment1/ will not be emitted as well I am talking a look on how to solve the issue now |
Yes, I do believe that will work for me. I didn't know about |
Comments are also always removed when placed after a function definition:
Neither the Those comments are really important for me since they are used by Unreal.js. |
@arthursw please log a new issue for a bug with a different repro |
I have the same problem that @arthursw has. I need to keep the comment but even though the file tsconfig.json says "removeComments": false or I use the /*! it does not preserve the comment. I I need them to turn on or off hints in my application |
+1 |
Again, please log a new issue with explicit repro steps |
I have added details to bug #16727 where the |
Reported by @NickHeiner in #3283
And I know that TS offers multiline strings via template strings, but here's another use case:
index.ts
tsconfig.json
Generated index.js
The
/* @ngInject */
comment needs to be there song-annotate
can annotate the Angular dependency injection function.The text was updated successfully, but these errors were encountered: