Skip to content

Commit

Permalink
Make props unpacking from #444 more robust
Browse files Browse the repository at this point in the history
  • Loading branch information
oyvindberg committed Jun 19, 2022
1 parent 7df50e7 commit 35921de
Showing 1 changed file with 9 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,15 @@ class ReactNamesProxy(reactNames: ReactNames, rewrites: IArray[CastConversion])

/* the portion of the type system implemented in ST is not powerful enough to handle these constructs */
def unpackedProps(propsRef: TypeRef): PropsRef =
if (reactNames.PropsWithWithoutRefQNames(propsRef.typeName)) PropsRef(propsRef.targs.head)
else if (reactNames.ComponentPropsWithWithoutRefQNames(propsRef.typeName)) PropsRef(propsRef.targs.head.targs.head)
else PropsRef(propsRef)
propsRef match {
case TypeRef(name, IArray.first(head), _) if reactNames.PropsWithWithoutRefQNames(name) =>
PropsRef(head)
case TypeRef(name, IArray.first(TypeRef(_, IArray.first(head), _)), _)
if reactNames.ComponentPropsWithWithoutRefQNames(name) =>
PropsRef(head)
case other =>
PropsRef(other)
}

val isElement: Set[QualifiedName] =
Set(reactNames.ReactElement, reactNames.JsxReactElement).flatMap(withRewritten)
Expand Down

0 comments on commit 35921de

Please sign in to comment.