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
8 changes: 8 additions & 0 deletions convert.go
Original file line number Diff line number Diff line change
Expand Up @@ -870,6 +870,14 @@ func (p parsedType) WithComments(comments ...string) parsedType {

// TODO: Return comments?
func (ts *Typescript) typescriptType(ty types.Type) (parsedType, error) {
// No matter what the type is, if we have some custom override, always use that.
custom, ok := ts.parsed.typeOverrides[ty.String()]
if ok {
return parsedType{
Value: custom(),
}, nil
}

switch ty := ty.(type) {
case *types.Signature:
// TODO: Handle functions better
Expand Down
10 changes: 10 additions & 0 deletions testdata/alias/alias.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,13 @@ type AliasStructNestedSlice = []AliasStructNested

// RemappedAlias should be manually remapped to "string" in the test settings.
type RemappedAlias = FooStruct

type UseAliasedType[G any] struct {
Field RemappedAlias
AsKey map[RemappedAlias]string
AsVal map[string]RemappedAlias
AsSlice []RemappedAlias
AsGeneric G
}

type GenericUseRemappedAlias = UseAliasedType[RemappedAlias]
18 changes: 18 additions & 0 deletions testdata/alias/alias.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,5 +36,23 @@ export interface FooStruct {
readonly Key: string;
}

// From alias/alias.go
export interface GenericUseRemappedAlias {
readonly Field: string;
readonly AsKey: Record<string, string> | null;
readonly AsVal: Record<string, string> | null;
readonly AsSlice: readonly string[];
readonly AsGeneric: string;
}

// From alias/alias.go
export type RemappedAlias = string;

// From alias/alias.go
export interface UseAliasedType<G extends any> {
readonly Field: string;
readonly AsKey: Record<string, string> | null;
readonly AsVal: Record<string, string> | null;
readonly AsSlice: readonly string[];
readonly AsGeneric: G;
}