From fa70a2a650d15f8c10f41ccb3fbd5f12e1986970 Mon Sep 17 00:00:00 2001 From: Paul Gschwendtner Date: Mon, 23 Jul 2018 22:36:24 +0200 Subject: [PATCH] build(bazel): entry point file couldn't be resolved [ts-api-guardian] (#25052) * When using `ts-api-guardian` on Windows, the input file can't be found due to wrong normalized path delimiters. PR Close #25052 --- tools/ts-api-guardian/lib/serializer.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tools/ts-api-guardian/lib/serializer.ts b/tools/ts-api-guardian/lib/serializer.ts index 5e442b2e45..3deba37bc4 100644 --- a/tools/ts-api-guardian/lib/serializer.ts +++ b/tools/ts-api-guardian/lib/serializer.ts @@ -42,7 +42,9 @@ export function publicApi(fileName: string, options: SerializationOptions = {}): export function publicApiInternal( host: ts.CompilerHost, fileName: string, tsOptions: ts.CompilerOptions, options: SerializationOptions = {}): string { - const entrypoint = path.normalize(fileName); + // Since the entry point will be compared with the source files from the TypeScript program, + // the path needs to be normalized with forward slashes in order to work within Windows. + const entrypoint = path.normalize(fileName).replace(/\\/g, '/'); if (!entrypoint.match(/\.d\.ts$/)) { throw new Error(`Source file "${fileName}" is not a declaration file`);