forked from microsoft/TypeScript
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from dragomirtitian/nullish-coalescing-operator
Nullish coalescing operator
- Loading branch information
Showing
11 changed files
with
369 additions
and
4 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
//// [nullishCoalescingOperator8.ts] | ||
declare const a: { p: string | undefined, m(): string | undefined }; | ||
declare const b: { p: string | undefined, m(): string | undefined }; | ||
|
||
const n1 = a.p ?? "default"; | ||
const n2 = a.m() ?? "default"; | ||
const n3 = a.m() ?? b.p ?? b.m() ?? "default";; | ||
|
||
|
||
//// [nullishCoalescingOperator8.js] | ||
var _a, _b, _c, _d, _e; | ||
"use strict"; | ||
var n1 = (_a = a.p, _a !== void 0 && _a !== null ? _a : "default"); | ||
var n2 = (_b = a.m(), _b !== void 0 && _b !== null ? _b : "default"); | ||
var n3 = (_e = (_d = (_c = a.m(), _c !== void 0 && _c !== null ? _c : b.p), _d !== void 0 && _d !== null ? _d : b.m()), _e !== void 0 && _e !== null ? _e : "default"); | ||
; |
35 changes: 35 additions & 0 deletions
35
tests/baselines/reference/nullishCoalescingOperator8.symbols
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,35 @@ | ||
=== tests/cases/conformance/expressions/nullishCoalescingOperator/nullishCoalescingOperator8.ts === | ||
declare const a: { p: string | undefined, m(): string | undefined }; | ||
>a : Symbol(a, Decl(nullishCoalescingOperator8.ts, 0, 13)) | ||
>p : Symbol(p, Decl(nullishCoalescingOperator8.ts, 0, 18)) | ||
>m : Symbol(m, Decl(nullishCoalescingOperator8.ts, 0, 41)) | ||
|
||
declare const b: { p: string | undefined, m(): string | undefined }; | ||
>b : Symbol(b, Decl(nullishCoalescingOperator8.ts, 1, 13)) | ||
>p : Symbol(p, Decl(nullishCoalescingOperator8.ts, 1, 18)) | ||
>m : Symbol(m, Decl(nullishCoalescingOperator8.ts, 1, 41)) | ||
|
||
const n1 = a.p ?? "default"; | ||
>n1 : Symbol(n1, Decl(nullishCoalescingOperator8.ts, 3, 5)) | ||
>a.p : Symbol(p, Decl(nullishCoalescingOperator8.ts, 0, 18)) | ||
>a : Symbol(a, Decl(nullishCoalescingOperator8.ts, 0, 13)) | ||
>p : Symbol(p, Decl(nullishCoalescingOperator8.ts, 0, 18)) | ||
|
||
const n2 = a.m() ?? "default"; | ||
>n2 : Symbol(n2, Decl(nullishCoalescingOperator8.ts, 4, 5)) | ||
>a.m : Symbol(m, Decl(nullishCoalescingOperator8.ts, 0, 41)) | ||
>a : Symbol(a, Decl(nullishCoalescingOperator8.ts, 0, 13)) | ||
>m : Symbol(m, Decl(nullishCoalescingOperator8.ts, 0, 41)) | ||
|
||
const n3 = a.m() ?? b.p ?? b.m() ?? "default";; | ||
>n3 : Symbol(n3, Decl(nullishCoalescingOperator8.ts, 5, 5)) | ||
>a.m : Symbol(m, Decl(nullishCoalescingOperator8.ts, 0, 41)) | ||
>a : Symbol(a, Decl(nullishCoalescingOperator8.ts, 0, 13)) | ||
>m : Symbol(m, Decl(nullishCoalescingOperator8.ts, 0, 41)) | ||
>b.p : Symbol(p, Decl(nullishCoalescingOperator8.ts, 1, 18)) | ||
>b : Symbol(b, Decl(nullishCoalescingOperator8.ts, 1, 13)) | ||
>p : Symbol(p, Decl(nullishCoalescingOperator8.ts, 1, 18)) | ||
>b.m : Symbol(m, Decl(nullishCoalescingOperator8.ts, 1, 41)) | ||
>b : Symbol(b, Decl(nullishCoalescingOperator8.ts, 1, 13)) | ||
>m : Symbol(m, Decl(nullishCoalescingOperator8.ts, 1, 41)) | ||
|
46 changes: 46 additions & 0 deletions
46
tests/baselines/reference/nullishCoalescingOperator8.types
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,46 @@ | ||
=== tests/cases/conformance/expressions/nullishCoalescingOperator/nullishCoalescingOperator8.ts === | ||
declare const a: { p: string | undefined, m(): string | undefined }; | ||
>a : { p: string | undefined; m(): string | undefined; } | ||
>p : string | undefined | ||
>m : () => string | undefined | ||
|
||
declare const b: { p: string | undefined, m(): string | undefined }; | ||
>b : { p: string | undefined; m(): string | undefined; } | ||
>p : string | undefined | ||
>m : () => string | undefined | ||
|
||
const n1 = a.p ?? "default"; | ||
>n1 : string | ||
>a.p ?? "default" : string | ||
>a.p : string | undefined | ||
>a : { p: string | undefined; m(): string | undefined; } | ||
>p : string | undefined | ||
>"default" : "default" | ||
|
||
const n2 = a.m() ?? "default"; | ||
>n2 : string | ||
>a.m() ?? "default" : string | ||
>a.m() : string | undefined | ||
>a.m : () => string | undefined | ||
>a : { p: string | undefined; m(): string | undefined; } | ||
>m : () => string | undefined | ||
>"default" : "default" | ||
|
||
const n3 = a.m() ?? b.p ?? b.m() ?? "default";; | ||
>n3 : string | ||
>a.m() ?? b.p ?? b.m() ?? "default" : string | ||
>a.m() ?? b.p ?? b.m() : string | undefined | ||
>a.m() ?? b.p : string | undefined | ||
>a.m() : string | undefined | ||
>a.m : () => string | undefined | ||
>a : { p: string | undefined; m(): string | undefined; } | ||
>m : () => string | undefined | ||
>b.p : string | undefined | ||
>b : { p: string | undefined; m(): string | undefined; } | ||
>p : string | undefined | ||
>b.m() : string | undefined | ||
>b.m : () => string | undefined | ||
>b : { p: string | undefined; m(): string | undefined; } | ||
>m : () => string | undefined | ||
>"default" : "default" | ||
|
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
Oops, something went wrong.