diff --git a/bindings/bindings.go b/bindings/bindings.go index 517fef1..96075f3 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 ") @@ -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 { }