Skip to content

Commit fa70a2a

Browse files
devversionIgorMinar
authored andcommitted
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
1 parent bde4402 commit fa70a2a

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

tools/ts-api-guardian/lib/serializer.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,9 @@ export function publicApi(fileName: string, options: SerializationOptions = {}):
4242
export function publicApiInternal(
4343
host: ts.CompilerHost, fileName: string, tsOptions: ts.CompilerOptions,
4444
options: SerializationOptions = {}): string {
45-
const entrypoint = path.normalize(fileName);
45+
// Since the entry point will be compared with the source files from the TypeScript program,
46+
// the path needs to be normalized with forward slashes in order to work within Windows.
47+
const entrypoint = path.normalize(fileName).replace(/\\/g, '/');
4648

4749
if (!entrypoint.match(/\.d\.ts$/)) {
4850
throw new Error(`Source file "${fileName}" is not a declaration file`);

0 commit comments

Comments
 (0)