forked from microsoft/TypeScript
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathnullishCoalescingAssignmentVsPrivateFieldsJsEmit1.types
More file actions
50 lines (42 loc) · 1.44 KB
/
nullishCoalescingAssignmentVsPrivateFieldsJsEmit1.types
File metadata and controls
50 lines (42 loc) · 1.44 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
//// [tests/cases/conformance/expressions/nullishCoalescingOperator/nullishCoalescingAssignmentVsPrivateFieldsJsEmit1.ts] ////
=== nullishCoalescingAssignmentVsPrivateFieldsJsEmit1.ts ===
// https://github.com/microsoft/TypeScript/issues/61109
class Cls {
>Cls : Cls
> : ^^^
#privateProp: number | undefined;
>#privateProp : number | undefined
> : ^^^^^^^^^^^^^^^^^^
problem() {
>problem : () => void
> : ^^^^^^^^^^
this.#privateProp ??= false ? neverThis() : 20;
>this.#privateProp ??= false ? neverThis() : 20 : number
> : ^^^^^^
>this.#privateProp : number | undefined
> : ^^^^^^^^^^^^^^^^^^
>this : this
> : ^^^^
>false ? neverThis() : 20 : 20
> : ^^
>false : false
> : ^^^^^
>neverThis() : never
> : ^^^^^
>neverThis : () => never
> : ^^^^^^
>20 : 20
> : ^^
}
}
function neverThis(): never {
>neverThis : () => never
> : ^^^^^^
throw new Error("This should really really never happen!");
>new Error("This should really really never happen!") : Error
> : ^^^^^
>Error : ErrorConstructor
> : ^^^^^^^^^^^^^^^^
>"This should really really never happen!" : "This should really really never happen!"
> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
}