From 039a7ba828655cedfd34e1045b32430a1cbca450 Mon Sep 17 00:00:00 2001 From: Asger F Date: Tue, 17 May 2022 17:33:36 +0200 Subject: [PATCH] JS: Handle .d.mts files when generating module bindings --- javascript/extractor/lib/typescript/src/main.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/javascript/extractor/lib/typescript/src/main.ts b/javascript/extractor/lib/typescript/src/main.ts index eb3ce99a875..626c8a593b0 100644 --- a/javascript/extractor/lib/typescript/src/main.ts +++ b/javascript/extractor/lib/typescript/src/main.ts @@ -670,6 +670,12 @@ function handleOpenProjectCommand(command: OpenProjectCommand) { if (file.endsWith(".d.ts")) { return pathlib.basename(file, ".d.ts"); } + if (file.endsWith(".d.mts") || file.endsWith(".d.cts")) { + // We don't extract d.mts or d.cts files, but their symbol can coincide with that of a d.ts file, + // which means any module bindings we generate for it will ultimately be visible in QL. + let base = pathlib.basename(file); + return base.substring(0, base.length - '.d.mts'.length); + } let base = pathlib.basename(file); let dot = base.lastIndexOf('.'); return dot === -1 || dot === 0 ? base : base.substring(0, dot);