-
Notifications
You must be signed in to change notification settings - Fork 12.9k
[Transforms] Extract transformFiles call from printFile #8929
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
Conversation
…lso some additional cleanup.
export function getSourceTreeNodeOfType<T extends Node>(node: T, nodeTest: (node: Node) => node is T): T { | ||
const source = getSourceTreeNode(node); | ||
return source && nodeTest(source) ? source : undefined; | ||
export function getOriginalSourceFiles(sourceFiles: SourceFile[]) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
how is this function used? it doesn't seems to be use in this change.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's used for emitting declaration files: https://github.com/Microsoft/TypeScript/blob/transforms-extractFromPrinter/src/compiler/printer.ts#L197
return !isDeclarationFile(sourceFile) && !isExternalModule(sourceFile); | ||
} | ||
|
||
export function forEachEmitFile(host: EmitHost, sourceFiles: SourceFile[], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It will be great if you could comment the difference between forEachEmitFile
forEachExpectedEmitFile
. they are quite similar at a glace
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll add comments.
This is not related to this change. but just wonder why we still keep |
Clarification: |
Also to clarify: this change remove |
I have some stashed progress on this. The tricky part is ensuring we always read via the property, but write via
I'll update, thanks.
That is correct. |
Gotcha. Others than the comments, the change looks good. 👍 |
To reduce the number of closures created, this moves the call to
transformFiles
out ofprintFile
and into the main body ofprintFiles
.