Skip to content
Merged
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 @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion apps/api-extractor/src/api/IConfigFile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
31 changes: 31 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,31 @@
// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
Comment thread
bartvandenende-wm marked this conversation as resolved.
// 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);
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -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 "<projectFolder>".
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 "<projectFolder>".
Expand Down
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"
Comment thread
bartvandenende-wm marked this conversation as resolved.
}
Loading