Retain synthetic comments on exports.#25604
Conversation
|
/CC @weswigham |
410ca8d to
075690d
Compare
|
@weswigham I'm not 100% sure we want the changes in the last commit, i.e. retaining comments on export specifiers. The code paths setting allowComments=false (or rather, not passing it) sound as if they expect the comments to be emitted elsewhere, at least for export assignment and hoisted exports. |
71f0393 to
eba8e49
Compare
|
Actually I take it back, emitting comments for export specifiers is not a good idea. I'm having a really productive conversation with myself here, it seems ;-) |
eba8e49 to
cdfed60
Compare
|
@rbuckton can you please review this change. |
This pulls in the changes from microsoft/TypeScript#25604 that are required for tsickle to run purely based on transformers. This allows deleting a number of hacks in `transformer_utils.ts` on our side.
|
@rbuckton I'm seeing other problems, such as comments on initialized comments being emitted, e.g. from: class Foo {
// comment goes here
bar = 1;
}If I set class Foo {
constructor() {
// my synthetic comment
// comment goes here
this.bar = 1;
}
}The cause in this case I think is: https://github.com/Microsoft/TypeScript/blob/master/src/compiler/factory.ts#L3141 The code sets the text range of the new code, but ignores emit flags such as NoComments |
30a650a to
f35428c
Compare
Variables that do not have a local variable created get transformed into a single exports assignment expression. TypeScript previously just created a new expression and set the text range to retain original comments, but for synthetic comments, merging the emit nodes by setting the original node is required.
Previously, TypeScript would only set the text range when transforming import and export declarations, leading it to drop synthetic comments and emit flags. This commit sets the original node on the statements that contains the generated `require()` call (or similar, depending on module system), retaining emit flags and synthetic comments.
f35428c to
b7ee0e9
Compare
This pulls in the changes from microsoft/TypeScript#25604 that are required for tsickle to run purely based on transformers. This allows deleting a number of hacks in `transformer_utils.ts` on our side.
Keep emit flags set on the original node on a namespace or enum node. This prevents dropping flags like NoComments, which caused duplicated comment emits. Additionally, TypeScript would emit synthetic comments twice, once for the variable declaration, once for the module statement. This explicitly clears away synthetic comments on namespaces and enums if their synthetic comments have already been emitted on the corresponding variable statement.
11681ef to
c50a6f7
Compare
|
The approach that I'm taking in a7224ec now is to not consider comments "consumed" if a container node has a |
|
@rbuckton friendly ping. |
This pulls in the changes from microsoft/TypeScript#25604 that are required for tsickle to run purely based on transformers. This allows deleting a number of hacks in `transformer_utils.ts` on our side.
This pulls in the changes from microsoft/TypeScript#25604 that are required for tsickle to run purely based on transformers. This allows deleting a number of hacks in `transformer_utils.ts` on our side.
This pulls in the changes from microsoft/TypeScript#25604 that are required for tsickle to run purely based on transformers. This allows deleting a number of hacks in `transformer_utils.ts` on our side.
This pulls in the changes from microsoft/TypeScript#25604 that are required for tsickle to run purely based on transformers. This allows deleting a number of hacks in `transformer_utils.ts` on our side.
|
|
||
| setOriginalNode(moduleStatement, node); | ||
| if (varAdded) { | ||
| // If a variable was added, synthetic comments are mitted on it, not on the moduleStatement. |
|
|
||
| setOriginalNode(enumStatement, node); | ||
| if (varAdded) { | ||
| // If a variable was added, synthetic comments are mitted on it, not on the moduleStatement. |
|
thanks! |
Variables that do not have a local variable created get transformed into
a single exports assignment expression. TypeScript previously just
created a new expression and set the text range to retain original
comments, but for synthetic comments, merging the emit nodes by setting
the original node is required.
Fixes #17594