diff --git a/CHANGELOG.md b/CHANGELOG.md index 6cd802005..859d3357f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,7 @@ ### Bug Fixes - Correctly handle external link resolver link text when referencing an external symbol, #2700. +- Big integer literals are now supported as default values, #2721. - Corrected handling of `@link` tags present in comments at the start of source files. ### Thanks! diff --git a/src/lib/converter/convert-expression.ts b/src/lib/converter/convert-expression.ts index 938c361aa..8c4b229f7 100644 --- a/src/lib/converter/convert-expression.ts +++ b/src/lib/converter/convert-expression.ts @@ -24,11 +24,18 @@ export function convertExpression(expression: ts.Expression): string { case ts.SyntaxKind.FalseKeyword: case ts.SyntaxKind.NullKeyword: case ts.SyntaxKind.NumericLiteral: - case ts.SyntaxKind.PrefixUnaryExpression: + case ts.SyntaxKind.BigIntLiteral: case ts.SyntaxKind.Identifier: return expression.getText(); } + if (ts.isPrefixUnaryExpression(expression)) { + const inner = convertExpression(expression.operand); + if (inner != "...") { + return expression.getText(); + } + } + if ( ts.isArrayLiteralExpression(expression) && expression.elements.length === 0 diff --git a/src/test/converter2/issues/gh2721.ts b/src/test/converter2/issues/gh2721.ts new file mode 100644 index 000000000..634ca827e --- /dev/null +++ b/src/test/converter2/issues/gh2721.ts @@ -0,0 +1,3 @@ +export const big = 123n; + +export const neg = -123n; diff --git a/src/test/issues.c2.test.ts b/src/test/issues.c2.test.ts index b79e0912e..ce516f272 100644 --- a/src/test/issues.c2.test.ts +++ b/src/test/issues.c2.test.ts @@ -1780,4 +1780,10 @@ describe("Issue Tests", () => { { display: "resolver caption", target: "https://typedoc.org" }, ]); }); + + it("#2721 handles bigint literals in default values", () => { + const project = convert(); + equal(query(project, "big").defaultValue, "123n"); + equal(query(project, "neg").defaultValue, "-123n"); + }); });