From 813cf8d4640b16b744b368e06c2730f6b3569f2d Mon Sep 17 00:00:00 2001 From: Tom Haumersen Date: Wed, 19 Nov 2025 00:54:07 -0500 Subject: [PATCH 1/2] convert golang Deprecated: into JSDoc @deprecated --- bindings/bindings.go | 12 ++++++++++-- testdata/comments/comments.go | 6 ++++++ testdata/comments/comments.ts | 9 +++++++++ 3 files changed, 25 insertions(+), 2 deletions(-) diff --git a/bindings/bindings.go b/bindings/bindings.go index 517fef1..3a8650c 100644 --- a/bindings/bindings.go +++ b/bindings/bindings.go @@ -756,7 +756,7 @@ func (b *Bindings) CommentGojaObject(comments []SyntheticComment, object *goja.O sep := "" for _, cmt := range jsDoc { jsDocComment.WriteString(sep) - jsDocComment.WriteString(cmt.Text) + jsDocComment.WriteString(convertDeprecation(cmt.Text)) sep = "\n *" } jsDocComment.WriteString("\n ") @@ -779,7 +779,7 @@ func (b *Bindings) CommentGojaObject(comments []SyntheticComment, object *goja.O node, b.vm.ToValue(c.Leading), b.vm.ToValue(c.SingleLine), - b.vm.ToValue(c.Text), + b.vm.ToValue(convertDeprecation(c.Text)), b.vm.ToValue(c.TrailingNewLine), ) if err != nil { @@ -790,3 +790,11 @@ func (b *Bindings) CommentGojaObject(comments []SyntheticComment, object *goja.O return node, nil } + +func convertDeprecation(txt string) string { + if len(txt) > 13 && txt[:13] == " Deprecated: " { + return " @deprecated " + txt[13:] + } + + return txt +} diff --git a/testdata/comments/comments.go b/testdata/comments/comments.go index 1660dd7..8b41ba9 100644 --- a/testdata/comments/comments.go +++ b/testdata/comments/comments.go @@ -41,3 +41,9 @@ type BlockComment struct { // Constant is just a value const Constant = "value" // An inline note + +// DeprecatedComment is a comment with a deprecation note +// +// Deprecated: this type is no longer used +type DeprecatedComment struct { +} diff --git a/testdata/comments/comments.ts b/testdata/comments/comments.ts index 5c4abfe..b66c561 100644 --- a/testdata/comments/comments.ts +++ b/testdata/comments/comments.ts @@ -43,6 +43,15 @@ export interface CommentedStructure { export const Constant = "value"; // An inline note +// From comments/comments.go +/** + * DeprecatedComment is a comment with a deprecation note + * + * @deprecated this type is no longer used + */ +export interface DeprecatedComment { +} + // From comments/comments.go export interface InheritedCommentedStructure extends CommentedStructure { } From 78dec22d8f2bc875b83f3280881eb9c1296ac529 Mon Sep 17 00:00:00 2001 From: Tom Haumersen Date: Wed, 19 Nov 2025 11:39:06 -0500 Subject: [PATCH 2/2] remove deprecation from comments opting out of formatting --- bindings/bindings.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bindings/bindings.go b/bindings/bindings.go index 3a8650c..96075f3 100644 --- a/bindings/bindings.go +++ b/bindings/bindings.go @@ -779,7 +779,7 @@ func (b *Bindings) CommentGojaObject(comments []SyntheticComment, object *goja.O node, b.vm.ToValue(c.Leading), b.vm.ToValue(c.SingleLine), - b.vm.ToValue(convertDeprecation(c.Text)), + b.vm.ToValue(c.Text), b.vm.ToValue(c.TrailingNewLine), ) if err != nil {