From d6e5528abde334669b57df97f09fd2b1af30d255 Mon Sep 17 00:00:00 2001 From: Bart van den Ende Date: Mon, 8 Jun 2026 06:31:45 +0200 Subject: [PATCH 1/3] feat: Add support for new d.ts extension format when using TS moduleresolution 'bundler' or 'nodenext' --- apps/api-extractor/src/api/ExtractorConfig.ts | 7 +++-- apps/api-extractor/src/api/IConfigFile.ts | 2 +- .../src/api/test/ExtractorConfig.test.ts | 31 +++++++++++++++++++ .../src/schemas/api-extractor-template.json | 2 +- .../config/api-extractor.json | 2 +- 5 files changed, 39 insertions(+), 5 deletions(-) create mode 100644 apps/api-extractor/src/api/test/ExtractorConfig.test.ts diff --git a/apps/api-extractor/src/api/ExtractorConfig.ts b/apps/api-extractor/src/api/ExtractorConfig.ts index 34a46b8fd46..92d15c944ac 100644 --- a/apps/api-extractor/src/api/ExtractorConfig.ts +++ b/apps/api-extractor/src/api/ExtractorConfig.ts @@ -258,8 +258,11 @@ export class ExtractorConfig { path.join(__dirname, '../schemas/api-extractor-defaults.json') ); - /** Match all three flavors for type declaration files (.d.ts, .d.mts, .d.cts) */ - private static readonly _declarationFileExtensionRegExp: RegExp = /\.d\.(c|m)?ts$/i; + /** + * Match all three flavors for type declaration files (.d.ts, .d.mts, .d.cts) + * including the new TS 5 bundle resolutions (.d.\{extension\}.ts, .d.\{extension\}.mts, .d.\{extension\}.cts) + **/ + private static readonly _declarationFileExtensionRegExp: RegExp = /\.d(\.[^./\\]+)?\.(c|m)?ts$/i; /** {@inheritDoc IConfigFile.projectFolder} */ public readonly projectFolder: string; diff --git a/apps/api-extractor/src/api/IConfigFile.ts b/apps/api-extractor/src/api/IConfigFile.ts index f05b943f796..be56c14fd35 100644 --- a/apps/api-extractor/src/api/IConfigFile.ts +++ b/apps/api-extractor/src/api/IConfigFile.ts @@ -450,7 +450,7 @@ export interface IConfigFile { * * @remarks * - * The file extension must be ".d.ts" and not ".ts". + * The file extension must be a declaration file (e.g. ".d.ts", ".d.mts", ".d.{extension}.ts"), not ".ts". * The path is resolved relative to the "projectFolder" location. */ mainEntryPointFilePath: string; diff --git a/apps/api-extractor/src/api/test/ExtractorConfig.test.ts b/apps/api-extractor/src/api/test/ExtractorConfig.test.ts new file mode 100644 index 00000000000..1ab62e2c1c3 --- /dev/null +++ b/apps/api-extractor/src/api/test/ExtractorConfig.test.ts @@ -0,0 +1,31 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license. +// See LICENSE in the project root for license information. + +import { ExtractorConfig } from '../ExtractorConfig'; + +describe('ExtractorConfig', () => { + describe('hasDtsFileExtension', () => { + it.each([ + ['test.ts', false], + ['test.cts', false], + ['test.mts', false], + ['test.d.ts', true], + ['test.d.mts', true], + ['test.d.cts', true], + ['test.css', false], + ['test.css.ts', false], + ['test.css.d.ts', true], + ['test.d.css.ts', true], + ['test.json', false], + ['test.json.ts', false], + ['test.json.d.ts', true], + ['test.d.json.ts', true], + ['video.d.mp4.ts', true], + ['font.d.woff2.ts', true], + ['model.d.3mf.ts', true] + ])('file "%s" has dts file extension equals "%s"', (file, expected) => { + const result = ExtractorConfig.hasDtsFileExtension(file); + expect(result).toEqual(expected); + }); + }); +}); diff --git a/apps/api-extractor/src/schemas/api-extractor-template.json b/apps/api-extractor/src/schemas/api-extractor-template.json index 4e1f7be9e12..0f01118c2ec 100644 --- a/apps/api-extractor/src/schemas/api-extractor-template.json +++ b/apps/api-extractor/src/schemas/api-extractor-template.json @@ -38,7 +38,7 @@ * (REQUIRED) Specifies the .d.ts file to be used as the starting point for analysis. API Extractor * analyzes the symbols exported by this module. * - * The file extension must be ".d.ts" and not ".ts". + * The file extension must be a declaration file (e.g. ".d.ts", ".d.mts", ".d.{extension}.ts"), not ".ts". * * The path is resolved relative to the folder of the config file that contains the setting; to change this, * prepend a folder token such as "". diff --git a/build-tests-samples/heft-web-rig-library-tutorial/config/api-extractor.json b/build-tests-samples/heft-web-rig-library-tutorial/config/api-extractor.json index 4cd36c3e066..d09d72d73e6 100644 --- a/build-tests-samples/heft-web-rig-library-tutorial/config/api-extractor.json +++ b/build-tests-samples/heft-web-rig-library-tutorial/config/api-extractor.json @@ -40,7 +40,7 @@ * (REQUIRED) Specifies the .d.ts file to be used as the starting point for analysis. API Extractor * analyzes the symbols exported by this module. * - * The file extension must be ".d.ts" and not ".ts". + * The file extension must be a declaration file (e.g. ".d.ts", ".d.mts", ".d.{extension}.ts"), not ".ts". * * The path is resolved relative to the folder of the config file that contains the setting; to change this, * prepend a folder token such as "". From 78d1027cfe6f4424c962a41336e04990889ec42d Mon Sep 17 00:00:00 2001 From: Bart van den Ende Date: Mon, 8 Jun 2026 06:32:26 +0200 Subject: [PATCH 2/3] chore: add rush change --- .../bartvandenende-wm-4899_2026-06-08-04-32.json | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 common/changes/@microsoft/api-extractor/bartvandenende-wm-4899_2026-06-08-04-32.json diff --git a/common/changes/@microsoft/api-extractor/bartvandenende-wm-4899_2026-06-08-04-32.json b/common/changes/@microsoft/api-extractor/bartvandenende-wm-4899_2026-06-08-04-32.json new file mode 100644 index 00000000000..482159d3e36 --- /dev/null +++ b/common/changes/@microsoft/api-extractor/bartvandenende-wm-4899_2026-06-08-04-32.json @@ -0,0 +1,10 @@ +{ + "changes": [ + { + "packageName": "@microsoft/api-extractor", + "comment": "Add support for new d.ts extension format when using TS moduleResolution 'bundler' or 'nodenext'.", + "type": "patch" + } + ], + "packageName": "@microsoft/api-extractor" +} \ No newline at end of file From d062f647a8077fb768b754500006792df9bd6492 Mon Sep 17 00:00:00 2001 From: Bart van den Ende Date: Mon, 8 Jun 2026 06:34:31 +0200 Subject: [PATCH 3/3] chore: escape brackets --- apps/api-extractor/src/api/IConfigFile.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/api-extractor/src/api/IConfigFile.ts b/apps/api-extractor/src/api/IConfigFile.ts index be56c14fd35..c6c9d6e72c1 100644 --- a/apps/api-extractor/src/api/IConfigFile.ts +++ b/apps/api-extractor/src/api/IConfigFile.ts @@ -450,7 +450,7 @@ export interface IConfigFile { * * @remarks * - * The file extension must be a declaration file (e.g. ".d.ts", ".d.mts", ".d.{extension}.ts"), not ".ts". + * The file extension must be a declaration file (e.g. ".d.ts", ".d.mts", ".d.\{extension\}.ts"), not ".ts". * The path is resolved relative to the "projectFolder" location. */ mainEntryPointFilePath: string;