File: acceptSymbolAsWeakType.types

package info (click to toggle)
node-typescript 5.2.2-1
  • links: PTS, VCS
  • area: main
  • in suites: experimental
  • size: 497,488 kB
  • sloc: javascript: 2,107,274; makefile: 6; sh: 1
file content (107 lines) | stat: -rw-r--r-- 2,858 bytes parent folder | download
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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
//// [tests/cases/compiler/acceptSymbolAsWeakType.ts] ////

=== acceptSymbolAsWeakType.ts ===
const s: symbol = Symbol('s');
>s : symbol
>Symbol('s') : unique symbol
>Symbol : SymbolConstructor
>'s' : "s"

const ws = new WeakSet([s]);
>ws : WeakSet<symbol>
>new WeakSet([s]) : WeakSet<symbol>
>WeakSet : WeakSetConstructor
>[s] : symbol[]
>s : symbol

ws.add(s);
>ws.add(s) : WeakSet<symbol>
>ws.add : (value: symbol) => WeakSet<symbol>
>ws : WeakSet<symbol>
>add : (value: symbol) => WeakSet<symbol>
>s : symbol

ws.has(s);
>ws.has(s) : boolean
>ws.has : (value: symbol) => boolean
>ws : WeakSet<symbol>
>has : (value: symbol) => boolean
>s : symbol

ws.delete(s);
>ws.delete(s) : boolean
>ws.delete : (value: symbol) => boolean
>ws : WeakSet<symbol>
>delete : (value: symbol) => boolean
>s : symbol

const wm = new WeakMap([[s, false]]);
>wm : WeakMap<symbol, boolean>
>new WeakMap([[s, false]]) : WeakMap<symbol, boolean>
>WeakMap : WeakMapConstructor
>[[s, false]] : [symbol, false][]
>[s, false] : [symbol, false]
>s : symbol
>false : false

wm.set(s, true);
>wm.set(s, true) : WeakMap<symbol, boolean>
>wm.set : (key: symbol, value: boolean) => WeakMap<symbol, boolean>
>wm : WeakMap<symbol, boolean>
>set : (key: symbol, value: boolean) => WeakMap<symbol, boolean>
>s : symbol
>true : true

wm.has(s);
>wm.has(s) : boolean
>wm.has : (key: symbol) => boolean
>wm : WeakMap<symbol, boolean>
>has : (key: symbol) => boolean
>s : symbol

wm.get(s);
>wm.get(s) : boolean | undefined
>wm.get : (key: symbol) => boolean | undefined
>wm : WeakMap<symbol, boolean>
>get : (key: symbol) => boolean | undefined
>s : symbol

wm.delete(s);
>wm.delete(s) : boolean
>wm.delete : (key: symbol) => boolean
>wm : WeakMap<symbol, boolean>
>delete : (key: symbol) => boolean
>s : symbol

const wr = new WeakRef(s);
>wr : WeakRef<symbol>
>new WeakRef(s) : WeakRef<symbol>
>WeakRef : WeakRefConstructor
>s : symbol

wr.deref();
>wr.deref() : symbol | undefined
>wr.deref : () => symbol | undefined
>wr : WeakRef<symbol>
>deref : () => symbol | undefined

const f = new FinalizationRegistry(() => {});
>f : FinalizationRegistry<unknown>
>new FinalizationRegistry(() => {}) : FinalizationRegistry<unknown>
>FinalizationRegistry : FinalizationRegistryConstructor
>() => {} : () => void

f.register(s, null);
>f.register(s, null) : void
>f.register : (target: WeakKey, heldValue: unknown, unregisterToken?: WeakKey | undefined) => void
>f : FinalizationRegistry<unknown>
>register : (target: WeakKey, heldValue: unknown, unregisterToken?: WeakKey | undefined) => void
>s : symbol

f.unregister(s);
>f.unregister(s) : void
>f.unregister : (unregisterToken: WeakKey) => void
>f : FinalizationRegistry<unknown>
>unregister : (unregisterToken: WeakKey) => void
>s : symbol