Skip to content

Commit

Permalink
Change getCurrentDirectory behaviour for TypeScript 2.3 and below
Browse files Browse the repository at this point in the history
  • Loading branch information
johnnyreilly committed Oct 18, 2017
1 parent a91a8b4 commit 173bd4c
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/servicesHost.ts
Expand Up @@ -48,6 +48,11 @@ export function makeServicesHost(
readFile: readFileWithFallback
};

// loader.context seems to work fine on Linux / Mac regardless causes problems for @types resolution on Windows for TypeScript < 2.3
const getCurrentDirectory = (compiler!.version && semver.gte(compiler!.version, '2.3.0'))
? () => loader.context
: () => process.cwd();

const resolutionStrategy = (compiler!.version && semver.gte(compiler!.version, '2.4.0'))
? resolutionStrategyTS24AndAbove
: resolutionStrategyTS23AndBelow;
Expand Down Expand Up @@ -98,7 +103,7 @@ export function makeServicesHost(
readFile: compiler.sys ? compiler.sys.readFile : undefined,
readDirectory: compiler.sys ? compiler.sys.readDirectory : undefined,

getCurrentDirectory: () => loader.context,
getCurrentDirectory,

getCompilationSettings: () => compilerOptions,
getDefaultLibFileName: (options: typescript.CompilerOptions) => compiler.getDefaultLibFilePath(options),
Expand Down

0 comments on commit 173bd4c

Please sign in to comment.