diff --git a/config/mutations.go b/config/mutations.go index ae26b43..d75346e 100644 --- a/config/mutations.go +++ b/config/mutations.go @@ -374,11 +374,12 @@ func InterfaceToType(ts *guts.Typescript) { // Replace the interface with a type alias ts.ReplaceNode(key, &bindings.Alias{ - Name: intf.Name, - Modifiers: intf.Modifiers, - Type: typeLiteral, - Parameters: intf.Parameters, - Source: intf.Source, + Name: intf.Name, + Modifiers: intf.Modifiers, + Type: typeLiteral, + Parameters: intf.Parameters, + Source: intf.Source, + SupportComments: intf.SupportComments, }) }) } diff --git a/testdata/interfacetotype-comments/interfacetotype-comments.go b/testdata/interfacetotype-comments/interfacetotype-comments.go new file mode 100644 index 0000000..9f568d8 --- /dev/null +++ b/testdata/interfacetotype-comments/interfacetotype-comments.go @@ -0,0 +1,29 @@ +package codersdk + +// User represents a user in the system. +// This comment should be preserved after conversion to a type alias. +type User struct { + // ID is the unique identifier + ID string `json:"id"` + // Name is the user's full name + Name string `json:"name"` + // Email is the user's email address + Email string `json:"email"` +} + +// Address contains location information. +type Address struct { + // Street address + Street string `json:"street"` + // City name + City string `json:"city"` +} + +// Profile combines user and address information. +// It extends multiple types. +type Profile struct { + User + Address + // Bio is the user's biography + Bio string `json:"bio"` +} diff --git a/testdata/interfacetotype-comments/interfacetotype-comments.ts b/testdata/interfacetotype-comments/interfacetotype-comments.ts new file mode 100644 index 0000000..91127e4 --- /dev/null +++ b/testdata/interfacetotype-comments/interfacetotype-comments.ts @@ -0,0 +1,48 @@ +// Code generated by 'guts'. DO NOT EDIT. + +// From codersdk/interfacetotype-comments.go +/** + * Address contains location information. + */ +export type Address = { + /** + * Street address + */ + street: string; + /** + * City name + */ + city: string; +}; + +// From codersdk/interfacetotype-comments.go +/** + * Profile combines user and address information. + * It extends multiple types. + */ +export type Profile = User & Address & { + /** + * Bio is the user's biography + */ + bio: string; +}; + +// From codersdk/interfacetotype-comments.go +/** + * User represents a user in the system. + * This comment should be preserved after conversion to a type alias. + */ +export type User = { + /** + * ID is the unique identifier + */ + id: string; + /** + * Name is the user's full name + */ + name: string; + /** + * Email is the user's email address + */ + email: string; +}; diff --git a/testdata/interfacetotype-comments/mutations b/testdata/interfacetotype-comments/mutations new file mode 100644 index 0000000..92ae551 --- /dev/null +++ b/testdata/interfacetotype-comments/mutations @@ -0,0 +1 @@ +InterfaceToType,ExportTypes,ReadOnly \ No newline at end of file