swc/crates/swc_ecma_parser/tests/tsc/nullishCoalescingOperator5.ts

42 lines
638 B
TypeScript

// @strict: true
declare const a: string | undefined
declare const b: string | undefined
declare const c: string | undefined
// should be a syntax error
a ?? b || c;
// should be a syntax error
a || b ?? c;
// should be a syntax error
a ?? b && c;
// should be a syntax error
a && b ?? c;
// Valid according to spec
a ?? (b || c);
// Valid according to spec
(a ?? b) || c;
// Valid according to spec
(a || b) ?? c;
// Valid according to spec
a || (b ?? c);
// Valid according to spec
a ?? (b && c);
// Valid according to spec
(a ?? b) && c;
// Valid according to spec
(a && b) ?? c;
// Valid according to spec
a && (b ?? c);