Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions apps/api-extractor/src/api/ExtractorConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
28 changes: 28 additions & 0 deletions apps/api-extractor/src/api/test/ExtractorConfig.test.ts
Original file line number Diff line number Diff line change
@@ -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);
});
});
});
Original file line number Diff line number Diff line change
@@ -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"
}
Loading