Skip to content

Commit c973c3f

Browse files
authored
fix: do not generate a type for interfaces (#58)
1 parent af054c2 commit c973c3f

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

convert.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -504,8 +504,15 @@ func (ts *Typescript) parse(obj types.Object) error {
504504
})
505505
}
506506

507+
if underNamed.NumEmbeddeds() == 0 && underNamed.NumMethods() > 0 {
508+
// type <Name> interface{ <methods> }
509+
// Do not generate anything for interfaces.
510+
return nil
511+
}
512+
507513
if underNamed.NumEmbeddeds() == 0 {
508514
// type <Name> interface{}
515+
// A typed `any` is still a type. A strange one to use, but still valid.
509516
// TODO: This has not been fully investigated. This line should only be triggered
510517
// on simple `any` types. If this generates something more complex, this will be wrong.
511518
ts.updateNode(objectIdentifier.Ref(), func(n *typescriptNode) {

testdata/interface/interface.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,3 @@ export interface Foo extends Bar, GenBar<string> {
1616
export interface GenBar<T extends Comparable> {
1717
readonly GenBarField: T;
1818
}
19-
20-
// From codersdk/interface.go
21-
export type IgnoreMe = any;

0 commit comments

Comments
 (0)