From 6976cf527742e620688c39180ee89df446b1bca5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=98yvind=20Raddum=20Berg?= Date: Mon, 19 Sep 2022 17:58:59 +0200 Subject: [PATCH] Guard against rewriting an intersection type alias to interface when one of the parts of the intersection is a type parameter. Fixes #467 (#475) --- .../converter/internal/ts/transforms/PreferTypeAlias.scala | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/ts/src/main/scala/org/scalablytyped/converter/internal/ts/transforms/PreferTypeAlias.scala b/ts/src/main/scala/org/scalablytyped/converter/internal/ts/transforms/PreferTypeAlias.scala index da64c4228c..bc9063b310 100644 --- a/ts/src/main/scala/org/scalablytyped/converter/internal/ts/transforms/PreferTypeAlias.scala +++ b/ts/src/main/scala/org/scalablytyped/converter/internal/ts/transforms/PreferTypeAlias.scala @@ -282,8 +282,10 @@ object PreferTypeAlias { x match { case ta @ TsDeclTypeAlias(comments, declared, name, tparams, alias, codePath) if map.contains(codePath.forceHasPath.codePath) => + val isTypeParam = TsTypeParam.asTypeArgs(tparams).toSet + alias match { - case TsTypeIntersect(AllTypeRefs(typeRefs)) => + case TsTypeIntersect(AllTypeRefs(typeRefs)) if !typeRefs.exists(isTypeParam) => TsDeclInterface(comments, declared, name, tparams, inheritance = typeRefs, members = Empty, codePath) case TsTypeObject(_, members) => TsDeclInterface(comments, declared, name, tparams, Empty, members, codePath)