mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-19 10:41:56 -05:00
[Release-2.0] Fix 9662: Visual Studio 2015 with TS2.0 gives incorrect @types path resolution errors (#9867)
* Change the shape of the shim layer to support getAutomaticTypeDirectives * Change the key for looking up automatic type-directives * Update baselines from change look-up name of type-directives * Add @currentDirectory into the test * Update baselines * Fix linting error * Address PR: fix spelling mistake * Instead of return path of the type directive names just return type directive names
This commit is contained in:
@@ -1886,7 +1886,7 @@ namespace ts {
|
||||
};
|
||||
}
|
||||
|
||||
// Cache host information about scrip Should be refreshed
|
||||
// Cache host information about script should be refreshed
|
||||
// at each language service public entry point, since we don't know when
|
||||
// set of scripts handled by the host changes.
|
||||
class HostCache {
|
||||
|
||||
@@ -72,8 +72,13 @@ namespace ts {
|
||||
directoryExists(directoryName: string): boolean;
|
||||
}
|
||||
|
||||
/** Public interface of the the of a config service shim instance.*/
|
||||
export interface CoreServicesShimHost extends Logger, ModuleResolutionHost {
|
||||
/** Public interface of the core-services host instance used in managed side */
|
||||
export interface CoreServicesShimHost extends Logger {
|
||||
directoryExists(directoryName: string): boolean;
|
||||
fileExists(fileName: string): boolean;
|
||||
getCurrentDirectory(): string;
|
||||
getDirectories(path: string): string;
|
||||
|
||||
/**
|
||||
* Returns a JSON-encoded value of the type: string[]
|
||||
*
|
||||
@@ -81,9 +86,14 @@ namespace ts {
|
||||
* when enumerating the directory.
|
||||
*/
|
||||
readDirectory(rootDir: string, extension: string, basePaths?: string, excludeEx?: string, includeFileEx?: string, includeDirEx?: string, depth?: number): string;
|
||||
useCaseSensitiveFileNames?(): boolean;
|
||||
getCurrentDirectory(): string;
|
||||
|
||||
/**
|
||||
* Read arbitary text files on disk, i.e. when resolution procedure needs the content of 'package.json' to determine location of bundled typings for node modules
|
||||
*/
|
||||
readFile(fileName: string): string;
|
||||
realpath?(path: string): string;
|
||||
trace(s: string): void;
|
||||
useCaseSensitiveFileNames?(): boolean;
|
||||
}
|
||||
|
||||
///
|
||||
@@ -240,6 +250,7 @@ namespace ts {
|
||||
}
|
||||
|
||||
export interface CoreServicesShim extends Shim {
|
||||
getAutomaticTypeDirectiveNames(compilerOptionsJson: string): string;
|
||||
getPreProcessedFileInfo(fileName: string, sourceText: IScriptSnapshot): string;
|
||||
getTSConfigFileInfo(fileName: string, sourceText: IScriptSnapshot): string;
|
||||
getDefaultCompilationSettings(): string;
|
||||
@@ -492,6 +503,10 @@ namespace ts {
|
||||
private readDirectoryFallback(rootDir: string, extension: string, exclude: string[]) {
|
||||
return JSON.parse(this.shimHost.readDirectory(rootDir, extension, JSON.stringify(exclude)));
|
||||
}
|
||||
|
||||
public getDirectories(path: string): string[] {
|
||||
return JSON.parse(this.shimHost.getDirectories(path));
|
||||
}
|
||||
}
|
||||
|
||||
function simpleForwardCall(logger: Logger, actionDescription: string, action: () => any, logPerformance: boolean): any {
|
||||
@@ -1003,7 +1018,7 @@ namespace ts {
|
||||
|
||||
public getPreProcessedFileInfo(fileName: string, sourceTextSnapshot: IScriptSnapshot): string {
|
||||
return this.forwardJSONCall(
|
||||
"getPreProcessedFileInfo('" + fileName + "')",
|
||||
`getPreProcessedFileInfo('${fileName}')`,
|
||||
() => {
|
||||
// for now treat files as JavaScript
|
||||
const result = preProcessFile(sourceTextSnapshot.getText(0, sourceTextSnapshot.getLength()), /* readImportFiles */ true, /* detectJavaScriptImports */ true);
|
||||
@@ -1017,6 +1032,16 @@ namespace ts {
|
||||
});
|
||||
}
|
||||
|
||||
public getAutomaticTypeDirectiveNames(compilerOptionsJson: string): string {
|
||||
return this.forwardJSONCall(
|
||||
`getAutomaticTypeDirectiveNames('${compilerOptionsJson}')`,
|
||||
() => {
|
||||
const compilerOptions = <CompilerOptions>JSON.parse(compilerOptionsJson);
|
||||
return getAutomaticTypeDirectiveNames(compilerOptions, this.host);
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
private convertFileReferences(refs: FileReference[]): IFileReference[] {
|
||||
if (!refs) {
|
||||
return undefined;
|
||||
|
||||
Reference in New Issue
Block a user