Skip to content

Commit 85300f5

Browse files
committed
Wrap the generated patternProperties comments in code quotes to fix TSDoc issues.
1 parent dd36825 commit 85300f5

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"changes": [
3+
{
4+
"packageName": "@rushstack/heft-json-schema-typings-plugin",
5+
"comment": "Fix TSDoc parse warnings caused by `@` characters in generated type definitions. The `json-schema-to-typescript` library emits JSDoc comments containing raw JSON Schema pattern values (e.g. `\"^@[^\\s]*$\"`), which TSDoc interprets as tag indicators. These values are now wrapped in backtick code spans to prevent the warnings.",
6+
"type": "minor"
7+
}
8+
],
9+
"packageName": "@rushstack/heft-json-schema-typings-plugin"
10+
}

heft-plugins/heft-json-schema-typings-plugin/src/JsonSchemaTypingsGenerator.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,15 @@ export class JsonSchemaTypingsGenerator extends TypingsGenerator {
6060
format: formatWithPrettier
6161
});
6262

63+
// The json-schema-to-typescript library generates JSDoc comments containing
64+
// inline values that may include "@" characters, such as:
65+
// via the `patternProperty` "^@[^\s]*$".
66+
// TSDoc interprets "@" as a tag indicator, causing parse warnings.
67+
// Wrap double-quoted values in backtick code spans to prevent this issue.
68+
// Use " +" for the leading whitespace so this matches at any JSDoc indentation
69+
// level (e.g. top-level " * ..." or nested " * ...").
70+
typings = typings.replace(/^( +\* .+`(?:patternProperty|definition)`) "([^"]+)"/gm, '$1 `"$2"`');
71+
6372
// Check for an "x-tsdoc-release-tag" property in the schema (e.g. "@public" or "@beta").
6473
// If present, inject the tag into JSDoc comments for all exported declarations.
6574
if (tsdocReleaseTag) {

0 commit comments

Comments
 (0)