When writing custom matchers for Adobe applications—After Effects, Premiere Pro, Illustrator—you will quickly run into a TypeScript friction point. TheDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/Octopodo/kt-testing-suite-core/llms.txt
Use this file to discover all available pages before exploring further.
Matcher<any> interface types this.actual as any, and inside a matcher function TypeScript cannot infer that any is actually an AVLayer. The moment you access a property like layer.source.mainSource, the compiler either raises a type error or offers no IntelliSense at all. KT Testing Suite ships two small but precise utilities—asAdobeType<T> and isAdobeType—to resolve this cleanly, without reaching for unsafe double casts or scattering // @ts-ignore comments through your matchers.
Both helpers are exported from the top-level kt-testing-suite-core package alongside extendMatchers, expect, and the rest of the public API.
asAdobeType<T>(value: any): T
asAdobeType is a compile-time type assertion. It casts any value through unknown to T, which is the TypeScript-approved way to perform a forced cast without a direct any → T assignment error:
unknown satisfies the TypeScript compiler’s strict checks while producing zero additional JavaScript at runtime—the compiled output is identical to just using the raw value. Its purpose is entirely to unlock the type information you need in your editor: IntelliSense, property access, and refactoring support all flow from the return type T.
When to use it: Any time you know that this.actual is an Adobe type and you want to access its properties without compiler errors or manual casts scattered through your code.
isAdobeType<T>(value: any, constructor): value is T
isAdobeType is a runtime type guard. It wraps instanceof and returns a TypeScript type predicate (value is T), which means the compiler narrows the type of value to T inside any if block that checks the guard:
asAdobeType, this check actually executes at runtime in the Adobe host. Use it when you cannot guarantee what this.actual contains and want a graceful failure path instead of a hard crash.
When to use it: When a matcher should handle both matching and non-matching types gracefully, or when you want to emit a descriptive failure message rather than an opaque Adobe runtime error.
Combining Both Helpers
The two utilities work well together: useisAdobeType to guard the early-exit path, then asAdobeType to get the typed variable you will actually work with. The isAdobeType guard narrows TypeScript’s view of this.actual, but this.actual is still typed as any in the Matcher<any> context, so asAdobeType provides the clean typed binding for the rest of the matcher body.
Complete Adobe Matchers Example
The following example assembles several matchers for After Effects layer types into a single exportedMatcher<any> object that can be passed to extendMatchers. It is adapted from the extensibility documentation for the suite.
Using Adobe Matchers in Tests
Benefits at a Glance
| Benefit | Detail |
|---|---|
| Type safety | Eliminates TypeScript compilation errors when accessing Adobe-specific properties inside Matcher<any> methods |
| IntelliSense | Full autocomplete for Adobe API properties once asAdobeType<T> is called |
| Runtime safety | isAdobeType guards prevent opaque Adobe runtime errors from untypeable objects |
| Reusability | Works with any Adobe application that exposes ExtendScript types—After Effects, Premiere Pro, Illustrator, and more |
| Clean code | A single asAdobeType<AVLayer>(this.actual) replaces repetitive this.actual as unknown as AVLayer patterns throughout a file |
Both
asAdobeType and isAdobeType are thin wrappers with no dependencies. asAdobeType compiles to return value; with the cast erased, and isAdobeType compiles to return value instanceof constructor;. There is no runtime overhead beyond what you would write manually.