-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
2,741 additions
and
1,342 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
/** | ||
* Used internally by `UnwrapComponent<T>` to unwrap a single layer decorator-wrapped component | ||
* @private | ||
*/ | ||
export type _UnwrapComponent<T> = T extends React.MemoExoticComponent< | ||
infer TMemoComponent | ||
> | ||
? TMemoComponent | ||
: T extends React.LazyExoticComponent<infer TLazyComponent> | ||
? TLazyComponent | ||
: "WrappedComponent" extends keyof T | ||
// @ts-ignore | ||
? T["WrappedComponent"] | ||
: T; | ||
|
||
/** | ||
* Unwraps the decorated typings from a decorator-wrapped components to provide the original type of the underlying | ||
* component. Useful in unit testing when stubbing decorators with the identity function. | ||
* | ||
* Note: This will unwrap up to 8 layers of decorators as although TypeScript supports recursive types, it does not | ||
* allow recursive type arguments. If more levels are required, you may use the `_UnwrapComponent<T>` type to unwrap | ||
* a single layer at a time. | ||
*/ | ||
export type UnwrapComponent<T> = _UnwrapComponent< | ||
_UnwrapComponent< | ||
_UnwrapComponent< | ||
_UnwrapComponent< | ||
_UnwrapComponent< | ||
_UnwrapComponent<_UnwrapComponent<_UnwrapComponent<T>>> | ||
> | ||
> | ||
> | ||
> | ||
>; |
Oops, something went wrong.