-
Notifications
You must be signed in to change notification settings - Fork 13.2k
Look for source of dts file only if dts is not from node_modules unless we have project references in node_modules #61739
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
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 | ||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -1717,6 +1717,7 @@ export function createProgram(_rootNamesOrOptions: readonly string[] | CreatePro | |||||||||||||||||||||||||
| let projectReferenceRedirects: Map<Path, ResolvedProjectReference | false> | undefined; | ||||||||||||||||||||||||||
| let mapFromFileToProjectReferenceRedirects: Map<Path, Path> | undefined; | ||||||||||||||||||||||||||
| let mapFromToProjectReferenceRedirectSource: Map<Path, SourceOfProjectReferenceRedirect> | undefined; | ||||||||||||||||||||||||||
| let hasResolvedReferencencesInNodeModules = false; | ||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
| let hasResolvedReferencencesInNodeModules = false; | |
| // Tracks whether `.d.ts` sources from `node_modules` have been resolved. | |
| let hasResolvedReferencencesInNodeModules = false; |
Copilot
AI
May 20, 2025
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.
[nitpick] The pathContainsNodeModules check appears in multiple places. Extracting it into a well-named helper (e.g., isInNodeModules(path)) could reduce duplication and improve readability.
| function getSourceOfProjectReferenceRedirect(path: Path) { | |
| if (!isDeclarationFileName(path)) return undefined; | |
| if (!hasResolvedReferencencesInNodeModules && pathContainsNodeModules(path)) return undefined; | |
| if (mapFromToProjectReferenceRedirectSource === undefined) { | |
| function isInNodeModules(path: Path): boolean { | |
| return pathContainsNodeModules(path); | |
| } | |
| function getSourceOfProjectReferenceRedirect(path: Path) { | |
| if (!isDeclarationFileName(path)) return undefined; | |
| if (!hasResolvedReferencencesInNodeModules && isInNodeModules(path)) return undefined; | |
| if (mapFromToProjectReferenceRedirectSource === undefined) { |
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.
There's a typo in the variable name
hasResolvedReferencencesInNodeModules. Consider renaming it tohasResolvedReferencesInNodeModulesfor clarity and consistency.