* migrate nullish coalescing commit * add more test case * add branch type check test * add more tests * fix nullish precedence * update public api * add rescan question question token to fix regression * update public api baseline * Added tests that emit for nullish coalescing operator conforming with grammar restrictions when assertions are used. * Fixed emit to hoist temporary variables (they previously went undeclared). Added tests to ensure calls and property accesses are only called once. * use not equal to null * rename factory * add grammar check * fix more cases * Fix handling of nullish coalescing oprator in expando objects. * Fixed classifier to support ?? operator. * update baseline * accept baseline * fix review * update emitter and more testcase * update control flow * make linter happy * update libs * avoid unnecessary assert * fix typooo * Fixes for control-flow analysis
41 lines
638 B
TypeScript
41 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);
|