Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion convert.go
Original file line number Diff line number Diff line change
Expand Up @@ -506,7 +506,17 @@ func (ts *Typescript) parse(obj types.Object) error {

if underNamed.NumEmbeddeds() == 0 {
// type <Name> 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
}

Expand Down
2 changes: 2 additions & 0 deletions convert_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
3 changes: 3 additions & 0 deletions testdata/interface/interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,6 @@ export interface Foo extends Bar, GenBar<string> {
export interface GenBar<T extends Comparable> {
readonly GenBarField: T;
}

// From codersdk/interface.go
export type IgnoreMe = any;
8 changes: 8 additions & 0 deletions testdata/lintignore/lintignore.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package lintignore

type LintIgnore[T any] struct {
Foo T
AnyFoo any
}

type AnyThing any
12 changes: 12 additions & 0 deletions testdata/lintignore/lintignore.ts
Original file line number Diff line number Diff line change
@@ -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<T extends any> {
readonly Foo: T;
// empty interface{} type, falling back to unknown
readonly AnyFoo: unknown;
}
1 change: 1 addition & 0 deletions testdata/lintignore/mutations
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ExportTypes,ReadOnly,BiomeLintIgnoreAnyTypeParameters
2 changes: 1 addition & 1 deletion testdata/union/union.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}