-
Notifications
You must be signed in to change notification settings - Fork 13.2k
Do not create multiple sourceFile to single outputFile with project redirect as the output file is included by default #30721
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
Changes from all commits
3fdd66b
b559e81
602aec2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2266,8 +2266,13 @@ namespace ts { | |
|
|
||
| let redirectedPath: Path | undefined; | ||
| if (refFile) { | ||
| const redirect = getProjectReferenceRedirect(fileName); | ||
| if (redirect) { | ||
| const redirectProject = getProjectReferenceRedirectProject(fileName); | ||
| if (redirectProject) { | ||
| if (redirectProject.commandLine.options.outFile || redirectProject.commandLine.options.out) { | ||
| // Shouldnt create many to 1 mapping file in --out scenario | ||
| return undefined; | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Trying to see if I understand: Normally, if you call So you return early here because
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You do not want to return |
||
| } | ||
| const redirect = getProjectReferenceOutputName(redirectProject, fileName); | ||
| fileName = redirect; | ||
| // Once we start redirecting to a file, we can potentially come back to it | ||
| // via a back-reference from another file in the .d.ts folder. If that happens we'll | ||
|
|
@@ -2364,17 +2369,23 @@ namespace ts { | |
| } | ||
|
|
||
| function getProjectReferenceRedirect(fileName: string): string | undefined { | ||
| const referencedProject = getProjectReferenceRedirectProject(fileName); | ||
| return referencedProject && getProjectReferenceOutputName(referencedProject, fileName); | ||
| } | ||
|
|
||
| function getProjectReferenceRedirectProject(fileName: string) { | ||
| // Ignore dts or any of the non ts files | ||
| if (!resolvedProjectReferences || !resolvedProjectReferences.length || fileExtensionIs(fileName, Extension.Dts) || !fileExtensionIsOneOf(fileName, supportedTSExtensions)) { | ||
| return undefined; | ||
| } | ||
|
|
||
| // If this file is produced by a referenced project, we need to rewrite it to | ||
| // look in the output folder of the referenced project rather than the input | ||
| const referencedProject = getResolvedProjectReferenceToRedirect(fileName); | ||
| if (!referencedProject) { | ||
| return undefined; | ||
| } | ||
| return getResolvedProjectReferenceToRedirect(fileName); | ||
| } | ||
|
|
||
|
|
||
| function getProjectReferenceOutputName(referencedProject: ResolvedProjectReference, fileName: string) { | ||
| const out = referencedProject.commandLine.options.outFile || referencedProject.commandLine.options.out; | ||
| return out ? | ||
| changeExtension(out, Extension.Dts) : | ||
|
|
||
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.
What is
refFilein this function?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.
refFile is normally passed in if its trying to resolve imports/ or reference directives etc. thats the file in which import exists and hence the file is being added. The root files passed to program, when processed have refile as undefined.