From e48ad72b23d18496da0dc5ea903d5f0ca71f6f3b Mon Sep 17 00:00:00 2001 From: Steven Masley Date: Wed, 15 Oct 2025 16:52:07 -0500 Subject: [PATCH 1/4] feat: handle base `type any` case This may cause extra code being generated that was not previously there. --- convert.go | 12 +++++++++++- convert_test.go | 2 ++ testdata/interface/interface.ts | 3 +++ testdata/lintignore/lintignore.go | 8 ++++++++ testdata/lintignore/lintignore.ts | 12 ++++++++++++ testdata/lintignore/mutations | 1 + 6 files changed, 37 insertions(+), 1 deletion(-) create mode 100644 testdata/lintignore/lintignore.go create mode 100644 testdata/lintignore/lintignore.ts create mode 100644 testdata/lintignore/mutations diff --git a/convert.go b/convert.go index 6214f76..cc8d583 100644 --- a/convert.go +++ b/convert.go @@ -506,7 +506,17 @@ func (ts *Typescript) parse(obj types.Object) error { if underNamed.NumEmbeddeds() == 0 { // type interface{} - // TODO: We could convert the function signatures to typescript. + // TODO: This has not been fully investigated. This line should only be triggered + // on simple `any` types. If this generates something more complex, this will be wrong. + ts.updateNode(objectIdentifier.Ref(), func(n *typescriptNode) { + n.Node = &bindings.Alias{ + Name: objectIdentifier, + Modifiers: []bindings.Modifier{}, + Type: ptr(bindings.KeywordAny), + Parameters: []*bindings.TypeParameter{}, + Source: ts.location(obj), + } + }) return nil } diff --git a/convert_test.go b/convert_test.go index d5085b6..57f56a2 100644 --- a/convert_test.go +++ b/convert_test.go @@ -125,6 +125,8 @@ func TestGeneration(t *testing.T) { mutations = append(mutations, config.TrimEnumPrefix) case "InterfaceToType": mutations = append(mutations, config.InterfaceToType) + case "BiomeLintIgnoreAnyTypeParameters": + mutations = append(mutations, config.BiomeLintIgnoreAnyTypeParameters) default: t.Fatal("unknown mutation, add it to the list:", m) } diff --git a/testdata/interface/interface.ts b/testdata/interface/interface.ts index b46147f..1fd04ae 100644 --- a/testdata/interface/interface.ts +++ b/testdata/interface/interface.ts @@ -16,3 +16,6 @@ export interface Foo extends Bar, GenBar { export interface GenBar { readonly GenBarField: T; } + +// From codersdk/interface.go +export type IgnoreMe = any; diff --git a/testdata/lintignore/lintignore.go b/testdata/lintignore/lintignore.go new file mode 100644 index 0000000..3b7b2cc --- /dev/null +++ b/testdata/lintignore/lintignore.go @@ -0,0 +1,8 @@ +package lintignore + +type LintIgnore[T any] struct { + Foo T + AnyFoo any +} + +type AnyThing any diff --git a/testdata/lintignore/lintignore.ts b/testdata/lintignore/lintignore.ts new file mode 100644 index 0000000..53c8d2e --- /dev/null +++ b/testdata/lintignore/lintignore.ts @@ -0,0 +1,12 @@ +// Code generated by 'guts'. DO NOT EDIT. + +// From lintignore/lintignore.go +export type AnyThing = any; + +// From lintignore/lintignore.go +// biome-ignore lint lint/complexity/noUselessTypeConstraint: golang does 'any' for generics, typescript does not like it +export interface LintIgnore { + readonly Foo: T; + // empty interface{} type, falling back to unknown + readonly AnyFoo: unknown; +} diff --git a/testdata/lintignore/mutations b/testdata/lintignore/mutations new file mode 100644 index 0000000..ecfd797 --- /dev/null +++ b/testdata/lintignore/mutations @@ -0,0 +1 @@ +ExportTypes,ReadOnly,BiomeLintIgnoreAnyTypeParameters \ No newline at end of file From 7fc0b9c0b0895751eb2323370c69a98883242772 Mon Sep 17 00:00:00 2001 From: Steven Masley Date: Wed, 15 Oct 2025 17:00:10 -0500 Subject: [PATCH 2/4] fix repeated test --- testdata/union/union.go | 2 +- testdata/union/union.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/testdata/union/union.go b/testdata/union/union.go index 9171f14..aa1bb4c 100644 --- a/testdata/union/union.go +++ b/testdata/union/union.go @@ -5,6 +5,6 @@ type UnionConstraint[T string | int64] struct { } // Repeated constraints are redundant -type Repeated[T string | string | int64 | uint64] struct { +type Repeated[T string | int64 | uint64] struct { Value T } diff --git a/testdata/union/union.ts b/testdata/union/union.ts index 15f2eb1..8cc0393 100644 --- a/testdata/union/union.ts +++ b/testdata/union/union.ts @@ -1,7 +1,7 @@ // Code generated by 'guts'. DO NOT EDIT. // From union/union.go -export interface Repeated { +export interface Repeated { readonly Value: T; } From a531c4a4c4f168b4eaf4e00fdc2900154ab1c6d4 Mon Sep 17 00:00:00 2001 From: Steven Masley Date: Wed, 15 Oct 2025 17:01:25 -0500 Subject: [PATCH 3/4] add newline --- testdata/lintignore/mutations | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/testdata/lintignore/mutations b/testdata/lintignore/mutations index ecfd797..1778f1f 100644 --- a/testdata/lintignore/mutations +++ b/testdata/lintignore/mutations @@ -1 +1 @@ -ExportTypes,ReadOnly,BiomeLintIgnoreAnyTypeParameters \ No newline at end of file +ExportTypes,ReadOnly,BiomeLintIgnoreAnyTypeParameters From 1502de7a377226a049e4dff27be0fe68c7c19e47 Mon Sep 17 00:00:00 2001 From: Steven Masley Date: Wed, 15 Oct 2025 17:03:14 -0500 Subject: [PATCH 4/4] rebase --- testdata/union/union.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/testdata/union/union.ts b/testdata/union/union.ts index 8cc0393..15f2eb1 100644 --- a/testdata/union/union.ts +++ b/testdata/union/union.ts @@ -1,7 +1,7 @@ // Code generated by 'guts'. DO NOT EDIT. // From union/union.go -export interface Repeated { +export interface Repeated { readonly Value: T; }