@@ -897,6 +897,7 @@ let emitTypeAliasesImpl
897897 ( baseName : string )
898898 flags overrideFunc
899899 ( ctx : Context )
900+ loc
900901 ( typrms : TypeParam list )
901902 ( target : text option )
902903 ( lines : {| name: string ; tyargs:( TypeParam * text ) list ; target: text option ; isOverload: bool |} -> 'a list ) =
@@ -911,16 +912,26 @@ let emitTypeAliasesImpl
911912 let name = Naming.createTypeNameOfArity arity None baseName
912913 let tyargs ' = List.take arity tyargs
913914 let typrms ' = List.take arity typrms
915+
916+ let bindings =
917+ createBindings ( ctx.currentNamespace @ [ name]) loc
918+ ( typrms |> List.skip arity)
919+ ( typrms |> List.skip arity |> List.map ( fun t ->
920+ match t.defaultType with
921+ | None -> impossible " emitTypeAliases"
922+ | Some t -> t
923+ ))
924+
914925 let target =
915926 Type.appOpt
916927 ( str baseName)
917928 [
918929 for tyarg in tyargs' do yield tyarg
919930 for t in typrms |> List.skip arity do
920- match t.defaultType with
921- | None -> impossible " emitTypeAliases"
922- | Some t -> yield emitType_ ctx t
931+ let t ' = repeatUntilEquilibrium ( substTypeVar bindings ctx) ( TypeVar t.name)
932+ yield emitType_ ctx t'
923933 ]
934+
924935 yield ! lines {| name = name; tyargs = List.zip typrms' tyargs'; target = Some target; isOverload = true |}
925936 ]
926937
@@ -1084,7 +1095,7 @@ let rec emitClass flags overrideFunc (ctx: Context) (current: StructuredText) (c
10841095 if useTags && innerCtx.options.inheritWithTags.HasProvide then
10851096 let alias =
10861097 emitTypeAliasesImpl
1087- " tags" flags overrideFunc innerCtx c.typeParams ( Some emittedLabels)
1098+ " tags" flags overrideFunc innerCtx c.loc c. typeParams ( Some emittedLabels)
10881099 ( fun x -> [ Statement.typeAlias false x.name ( x.tyargs |> List.map snd) x.target])
10891100 |> concat newline
10901101 alias |> TypeAliasText |> Some
@@ -1129,7 +1140,7 @@ let rec emitClass flags overrideFunc (ctx: Context) (current: StructuredText) (c
11291140 | ClassKind.ExportDefaultClass x -> getSelfTyText x.orig
11301141 | ClassKind.AnonymousInterface _ -> fallback
11311142
1132- emitTypeAliasesImpl " t" flags overrideFunc innerCtx c.typeParams selfTyText.ty ( fun x ->
1143+ emitTypeAliasesImpl " t" flags overrideFunc innerCtx c.loc c. typeParams selfTyText.ty ( fun x ->
11331144 if not x.isOverload then
11341145 [ TypeDefText {| name = x.name; tyargs = x.tyargs; body = x.target; isRec = selfTyText.isRec; shouldAssert = false |}]
11351146 else
@@ -1569,7 +1580,7 @@ let createStructuredText (rootCtx: Context) (stmts: Statement list) : Structured
15691580 let isRec =
15701581 knownTypes |> Set.contains ( KnownType.Ident ( ctx |> Context.getFullNameOfCurrentNamespace))
15711582 let items =
1572- emitTypeAliasesImpl " t" emitTypeFlags OverrideFunc.noOverride ctx ta.typeParams ( emitSelfType ctx ta.target |> Some) ( fun x ->
1583+ emitTypeAliasesImpl " t" emitTypeFlags OverrideFunc.noOverride ctx ta.loc ta. typeParams ( emitSelfType ctx ta.target |> Some) ( fun x ->
15731584 if not x.isOverload then
15741585 [ TypeDefText {| name = x.name; tyargs = x.tyargs; body = x.target; isRec = false ; shouldAssert = false |}]
15751586 else
0 commit comments