diff --git a/src/compiler/path.ts b/src/compiler/path.ts index 6a9374873b1a0..2d77043156abd 100644 --- a/src/compiler/path.ts +++ b/src/compiler/path.ts @@ -452,6 +452,11 @@ namespace ts { * Normalize path separators, converting `\` into `/`. */ export function normalizeSlashes(path: string): string { + const index = path.indexOf("\\"); + if (index === -1) { + return path; + } + backslashRegExp.lastIndex = index; // prime regex with known position return path.replace(backslashRegExp, directorySeparator); }