You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I encountered an issue with the type definitions for AVLayer, ShapeLayer, and TextLayer in the Types-for-Adobe . The current implementation defines both ShapeLayer and TextLayer as extends AVLayer. This causes problems when narrowing down layer types with type guards like isAVLayer, isShapeLayer, and isTextLayer.
For instance, when you try to narrow down the layer type to be either AVLayer, ShapeLayer, or TextLayer, TypeScript treats both ShapeLayer and TextLayer as subtypes of AVLayer due to inheritance. This causes the following issue: after narrowing with isAVLayer, TypeScript sees the else branch as a never type, preventing access to methods that should be available on ShapeLayer or TextLayer.
This leads to a situation where methods specific to ShapeLayer or TextLayer are inaccessible unless you use type assertions, which defeats the purpose of having separate type guards like isShapeLayer and isTextLayer.
Moreover, it is evident that AVLayer , ShapeLayer ,TextLayer are not overlapping
Here's a code example demonstrating the issue:
functionisAVLayer(layer: Layer): layer is AVLayer{returnlayerinstanceofAVLayer;}functionisShapeLayer(layer: Layer): layer is ShapeLayer{returnlayerinstanceofShapeLayer;}functionisTextLayer(layer: Layer): layer is TextLayer{returnlayerinstanceofTextLayer;}varfirstLayer=(app.project.activeItemasCompItem).selectedLayers[0];if(isAVLayer(firstLayer)||isShapeLayer(firstLayer)||isTextLayer(firstLayer)){if(isAVLayer(firstLayer)){firstLayer.effect.addProperty("ADBE Gaussian Blur 2");alert("is AVLayer");}elseif(isTextLayer(firstLayer)){firstLayer.effect.addProperty("ADBE Gaussian Blur 2");alert("is TextLayer");}elseif(isShapeLayer(firstLayer)){firstLayer.effect.addProperty("ADBE Gaussian Blur 2");alert("is ShapeLayer");}}
In this example, TypeScript incorrectly types the else branch as never, making it impossible to access methods on ShapeLayer or TextLayer unless manually type-asserted.
The text was updated successfully, but these errors were encountered:
Thank you for your response! I'm still quite new to TypeScript and not entirely sure how to resolve this issue. I hope someone else can help address this problem.
I encountered an issue with the type definitions for
AVLayer
,ShapeLayer
, andTextLayer
in theTypes-for-Adobe
. The current implementation defines bothShapeLayer
andTextLayer
asextends AVLayer
. This causes problems when narrowing down layer types with type guards likeisAVLayer
,isShapeLayer
, andisTextLayer
.For instance, when you try to narrow down the layer type to be either
AVLayer
,ShapeLayer
, orTextLayer
, TypeScript treats bothShapeLayer
andTextLayer
as subtypes ofAVLayer
due to inheritance. This causes the following issue: after narrowing withisAVLayer
, TypeScript sees theelse
branch as anever
type, preventing access to methods that should be available onShapeLayer
orTextLayer
.This leads to a situation where methods specific to
ShapeLayer
orTextLayer
are inaccessible unless you use type assertions, which defeats the purpose of having separate type guards likeisShapeLayer
andisTextLayer
.Moreover, it is evident that
AVLayer
,ShapeLayer
,TextLayer
are not overlappingHere's a code example demonstrating the issue:
In this example, TypeScript incorrectly types the else branch as never, making it impossible to access methods on ShapeLayer or TextLayer unless manually type-asserted.
The text was updated successfully, but these errors were encountered: