Skip to content

Commit e7d88ce

Browse files
committed
Fix declaration file check
Resolves #2647
1 parent 8a23089 commit e7d88ce

File tree

3 files changed

+10
-1
lines changed

3 files changed

+10
-1
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Unreleased
22

3+
### Bug Fixes
4+
5+
- The `suppressCommentWarningsInDeclarationFiles` option now correctly ignores warnings in `.d.cts` and `.d.mts` files, #2647.
6+
37
## v0.26.5 (2024-07-21)
48

59
### Features

src/lib/converter/comments/parser.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import type {
1818
} from "../../internationalization/internationalization";
1919
import { FileRegistry } from "../../models/FileRegistry";
2020
import { textContent, TextParserReentryState } from "./textParser";
21+
import { hasDeclarationFileExtension } from "../../utils/fs";
2122

2223
interface LookaheadGenerator<T> {
2324
done(): boolean;
@@ -111,7 +112,7 @@ export function parseComment(
111112
function warningImpl(message: TranslatedString, token: Token) {
112113
if (
113114
config.suppressCommentWarningsInDeclarationFiles &&
114-
file.fileName.endsWith(".d.ts")
115+
hasDeclarationFileExtension(file.fileName)
115116
) {
116117
return;
117118
}

src/lib/utils/fs.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -271,6 +271,10 @@ export function hasTsExtension(path: string): boolean {
271271
return /\.[cm]?ts$|\.tsx$/.test(path);
272272
}
273273

274+
export function hasDeclarationFileExtension(path: string) {
275+
return /\.d\.[cm]?ts$/.test(path);
276+
}
277+
274278
export function discoverInParentDir<T extends {}>(
275279
name: string,
276280
dir: string,

0 commit comments

Comments
 (0)