@@ -897,6 +897,7 @@ let emitTypeAliasesImpl
897
897
( baseName : string )
898
898
flags overrideFunc
899
899
( ctx : Context )
900
+ loc
900
901
( typrms : TypeParam list )
901
902
( target : text option )
902
903
( lines : {| name: string ; tyargs:( TypeParam * text ) list ; target: text option ; isOverload: bool |} -> 'a list ) =
@@ -911,16 +912,26 @@ let emitTypeAliasesImpl
911
912
let name = Naming.createTypeNameOfArity arity None baseName
912
913
let tyargs ' = List.take arity tyargs
913
914
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
+
914
925
let target =
915
926
Type.appOpt
916
927
( str baseName)
917
928
[
918
929
for tyarg in tyargs' do yield tyarg
919
930
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'
923
933
]
934
+
924
935
yield ! lines {| name = name; tyargs = List.zip typrms' tyargs'; target = Some target; isOverload = true |}
925
936
]
926
937
@@ -1084,7 +1095,7 @@ let rec emitClass flags overrideFunc (ctx: Context) (current: StructuredText) (c
1084
1095
if useTags && innerCtx.options.inheritWithTags.HasProvide then
1085
1096
let alias =
1086
1097
emitTypeAliasesImpl
1087
- " tags" flags overrideFunc innerCtx c.typeParams ( Some emittedLabels)
1098
+ " tags" flags overrideFunc innerCtx c.loc c. typeParams ( Some emittedLabels)
1088
1099
( fun x -> [ Statement.typeAlias false x.name ( x.tyargs |> List.map snd) x.target])
1089
1100
|> concat newline
1090
1101
alias |> TypeAliasText |> Some
@@ -1129,7 +1140,7 @@ let rec emitClass flags overrideFunc (ctx: Context) (current: StructuredText) (c
1129
1140
| ClassKind.ExportDefaultClass x -> getSelfTyText x.orig
1130
1141
| ClassKind.AnonymousInterface _ -> fallback
1131
1142
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 ->
1133
1144
if not x.isOverload then
1134
1145
[ TypeDefText {| name = x.name; tyargs = x.tyargs; body = x.target; isRec = selfTyText.isRec; shouldAssert = false |}]
1135
1146
else
@@ -1569,7 +1580,7 @@ let createStructuredText (rootCtx: Context) (stmts: Statement list) : Structured
1569
1580
let isRec =
1570
1581
knownTypes |> Set.contains ( KnownType.Ident ( ctx |> Context.getFullNameOfCurrentNamespace))
1571
1582
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 ->
1573
1584
if not x.isOverload then
1574
1585
[ TypeDefText {| name = x.name; tyargs = x.tyargs; body = x.target; isRec = false ; shouldAssert = false |}]
1575
1586
else
0 commit comments