diff --git a/packages/utils/src/typescript-installer.ts b/packages/utils/src/typescript-installer.ts index fc695bebb3..db65bbfb56 100644 --- a/packages/utils/src/typescript-installer.ts +++ b/packages/utils/src/typescript-installer.ts @@ -48,6 +48,7 @@ export function typeScriptPath(version: TsVersion, tsLocal: string | undefined): function installDir(version: TsVersion): string { assert(version !== "local"); + if (version === "next") version = TypeScriptVersion.latest; return path.join(installsDir, version); } diff --git a/packages/utils/test/typescript-installer.test.ts b/packages/utils/test/typescript-installer.test.ts new file mode 100644 index 0000000000..812058b5a2 --- /dev/null +++ b/packages/utils/test/typescript-installer.test.ts @@ -0,0 +1,17 @@ +import { typeScriptPath } from "../src/typescript-installer"; +import { TypeScriptVersion } from "@definitelytyped/typescript-versions"; +import * as os from "os"; +import * as path from "path"; + +describe("typeScriptPath", () => { + it("maps to temp folder", () => { + expect(typeScriptPath("3.4", undefined)).toEqual( + path.join(os.homedir(), ".dts", "typescript-installs", "3.4", "node_modules", "typescript") + ); + }); + it("maps next to latest typescript version", () => { + expect(typeScriptPath("next", undefined)).toEqual( + path.join(os.homedir(), ".dts", "typescript-installs", TypeScriptVersion.latest, "node_modules", "typescript") + ); + }); +});