Skip to content

Commit

Permalink
Guard against rewriting an intersection type alias to interface when …
Browse files Browse the repository at this point in the history
…one of the parts of the intersection is a type parameter. Fixes #467 (#475)
  • Loading branch information
oyvindberg authored Sep 19, 2022
1 parent 484388e commit 6976cf5
Showing 1 changed file with 3 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 6976cf5

Please sign in to comment.