Skip to content
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

Support 'isSourceFileFromExternalLibrary' for source files from '/// <reference types="" />'' #28004

Merged
3 commits merged into from
Oct 20, 2018

Conversation

ghost
Copy link

@ghost ghost commented Oct 19, 2018

Fixes another bug similar to #27917, also discovered via dtslint.
We need to annotate each ResolvedTypeReferenceDirective to indicate whether it came from node_modules, and increment currentNodeModulesDepth if so.

const candidate = combinePaths(typeRoot, typeReferenceDirectiveName);
const candidateDirectory = getDirectoryPath(candidate);
const directoryExists = directoryProbablyExists(candidateDirectory, host);
if (!directoryExists && traceEnabled) {
trace(host, Diagnostics.Directory_0_does_not_exist_skipping_all_lookups_in_it, candidateDirectory);
}
return resolvedTypeScriptOnly(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you not return as is and just add check at final destination since it seems like it can be unified since it all the time checks if pathContains node_modules ?

@ghost ghost force-pushed the referenceTypesIsExternal branch from 25b1968 to 6d74dbf Compare October 19, 2018 23:14
}
resolvedTypeReferenceDirective = { primary, resolvedFileName: resolved.fileName, packageId: resolved.packageId };
resolvedTypeReferenceDirective = { primary, resolvedFileName, packageId, isExternalLibraryImport: pathContainsNodeModules(resolvedFileName) };
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In node module resolver, isExternalLibraryImport is checked on path before realPath. https://github.com/Microsoft/TypeScript/blob/master/src/compiler/moduleNameResolver.ts#L903

@ghost ghost merged commit 72244c5 into master Oct 20, 2018
@ghost ghost deleted the referenceTypesIsExternal branch October 20, 2018 01:00
This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant