-
Notifications
You must be signed in to change notification settings - Fork 13.4k
Expand file tree
/
Copy pathdeclarationAssertionNodeNotReusedWhenTypeNotEquivalent1.types
More file actions
74 lines (59 loc) · 2.41 KB
/
declarationAssertionNodeNotReusedWhenTypeNotEquivalent1.types
File metadata and controls
74 lines (59 loc) · 2.41 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
//// [tests/cases/compiler/declarationAssertionNodeNotReusedWhenTypeNotEquivalent1.ts] ////
=== declarationAssertionNodeNotReusedWhenTypeNotEquivalent1.ts ===
type Wrapper<T> = {
>Wrapper : Wrapper<T>
> : ^^^^^^^^^^
_type: T;
>_type : T
> : ^
};
declare function stringWrapper(): Wrapper<string>;
>stringWrapper : () => Wrapper<string>
> : ^^^^^^
declare function objWrapper<T extends Record<string, Wrapper<any>>>(
>objWrapper : <T extends Record<string, Wrapper<any>>>(obj: T) => Wrapper<T>
> : ^ ^^^^^^^^^ ^^ ^^ ^^^^^
obj: T,
>obj : T
> : ^
): Wrapper<T>;
const value = objWrapper({
>value : Wrapper<{ prop1: Wrapper<"hello">; }>
> : ^^^^^^^^^^^^^^^^^ ^^^^
>objWrapper({ prop1: stringWrapper() as Wrapper<"hello">,}) : Wrapper<{ prop1: Wrapper<"hello">; }>
> : ^^^^^^^^^^^^^^^^^ ^^^^
>objWrapper : <T extends Record<string, Wrapper<any>>>(obj: T) => Wrapper<T>
> : ^ ^^^^^^^^^ ^^ ^^ ^^^^^
>{ prop1: stringWrapper() as Wrapper<"hello">,} : { prop1: Wrapper<"hello">; }
> : ^^^^^^^^^ ^^^
prop1: stringWrapper() as Wrapper<"hello">,
>prop1 : Wrapper<"hello">
> : ^^^^^^^^^^^^^^^^
>stringWrapper() as Wrapper<"hello"> : Wrapper<"hello">
> : ^^^^^^^^^^^^^^^^
>stringWrapper() : Wrapper<string>
> : ^^^^^^^^^^^^^^^
>stringWrapper : () => Wrapper<string>
> : ^^^^^^
});
type Unwrap<T> = T extends Wrapper<any>
>Unwrap : Unwrap<T>
> : ^^^^^^^^^
? T["_type"] extends Record<string, Wrapper<any>>
? { [Key in keyof T["_type"]]: Unwrap<T["_type"][Key]> }
: T["_type"]
: never;
declare function unwrap<T>(wrapper: T): Unwrap<T>;
>unwrap : <T>(wrapper: T) => Unwrap<T>
> : ^ ^^ ^^ ^^^^^
>wrapper : T
> : ^
export const unwrapped = unwrap(value);
>unwrapped : { prop1: "hello"; }
> : ^^^^^^^^^^^^^^^^^^^
>unwrap(value) : { prop1: "hello"; }
> : ^^^^^^^^^^^^^^^^^^^
>unwrap : <T>(wrapper: T) => Unwrap<T>
> : ^ ^^ ^^ ^^^^^
>value : Wrapper<{ prop1: Wrapper<"hello">; }>
> : ^^^^^^^^^^^^^^^^^ ^^^^