diff --git a/convert.go b/convert.go index 8d9c128..e2eea0d 100644 --- a/convert.go +++ b/convert.go @@ -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 diff --git a/testdata/alias/alias.go b/testdata/alias/alias.go index d218ec6..da948ca 100644 --- a/testdata/alias/alias.go +++ b/testdata/alias/alias.go @@ -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] diff --git a/testdata/alias/alias.ts b/testdata/alias/alias.ts index 78a482a..f7fd12e 100644 --- a/testdata/alias/alias.ts +++ b/testdata/alias/alias.ts @@ -36,5 +36,23 @@ export interface FooStruct { readonly Key: string; } +// From alias/alias.go +export interface GenericUseRemappedAlias { + readonly Field: string; + readonly AsKey: Record | null; + readonly AsVal: Record | null; + readonly AsSlice: readonly string[]; + readonly AsGeneric: string; +} + // From alias/alias.go export type RemappedAlias = string; + +// From alias/alias.go +export interface UseAliasedType { + readonly Field: string; + readonly AsKey: Record | null; + readonly AsVal: Record | null; + readonly AsSlice: readonly string[]; + readonly AsGeneric: G; +}