diff --git a/apps/api-extractor/src/api/ExtractorConfig.ts b/apps/api-extractor/src/api/ExtractorConfig.ts index 5f9a739c820..3bd42145232 100644 --- a/apps/api-extractor/src/api/ExtractorConfig.ts +++ b/apps/api-extractor/src/api/ExtractorConfig.ts @@ -257,8 +257,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(\.[a-z]+)?\.(c|m)?ts$/i; /** {@inheritDoc IConfigFile.projectFolder} */ public readonly projectFolder: 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..28b735289e4 --- /dev/null +++ b/apps/api-extractor/src/api/test/ExtractorConfig.test.ts @@ -0,0 +1,28 @@ +// 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] + ])('file "%s" has dts file extension equals "%s"', (file, expected) => { + const result = ExtractorConfig.hasDtsFileExtension(file); + expect(result).toEqual(expected); + }); + }); +}); diff --git a/common/changes/@rushstack/eslint-patch/bartvandenende-wm-4899_2024-10-01-07-19.json b/common/changes/@rushstack/eslint-patch/bartvandenende-wm-4899_2024-10-01-07-19.json new file mode 100644 index 00000000000..fdc04b30542 --- /dev/null +++ b/common/changes/@rushstack/eslint-patch/bartvandenende-wm-4899_2024-10-01-07-19.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