Fix #8738: Handles Re-assignment of Exported Clause Member#8739
Conversation
|
Hi @evansb, I'm your friendly neighborhood Microsoft Pull Request Bot (You can call me MSBOT). Thanks for your contribution! The agreement was validated by Microsoft and real humans are currently evaluating your PR. TTYL, MSBOT; |
| if (internalExportClauseMemberChanged) { | ||
| for (const specifier of exportSpecifiers[(<Identifier>node.left).text]) { | ||
| emitStart(specifier.name); | ||
| emitContainingModuleName(specifier); |
There was a problem hiding this comment.
this part is duplicated. we also need to handle default for ES3 to be emitted as ["default"] instead of .default.
There was a problem hiding this comment.
I don't quite get this part, why does ES3 exports["default"] has anything to do since we're changing exports members?
|
The latest commit handles postfix and prefix |
| for (const specifier of exportSpecifiers[name.text]) { | ||
| emitStart(specifier.name); | ||
| emitContainingModuleName(specifier); | ||
| write("."); |
There was a problem hiding this comment.
still does not handle default. see https://github.com/Microsoft/TypeScript/blob/master/src/compiler/emitter.ts#L1616-L1624
There was a problem hiding this comment.
Oh right, of course the identifier itself can be "default", didn't think of that. Thanks
| return isSourceFileLevelDeclarationInSystemJsModule(targetDeclaration, /*isExported*/ true); | ||
| } | ||
|
|
||
| function isNameOfExportedSourceLevelDeclarationInClauseModule(node: Node): boolean { |
There was a problem hiding this comment.
can you rename it to isNameOfExportedDeclarationInNonES6Module?
|
thanks @evansb! |
This Pull Request Fixes #8738.
When exporting a clause directly, TypeScript emits the member assignment to
exportsafter the variable declaration of the member. This ignores all assignment statement afterwards.Patch Summary:
When there is assignment operator expression
=, +=, etc, check if the target is a member of export clause. If it is, make sure that the export clause is updated.Behaviour before patch:
compiles to
Compile result after patch:
Export alias are updated as well, I use the same code for variable declaration.