TypeScript/tests/cases/conformance/salsa/typeFromPropertyAssignment9_1.ts
Wenlu Wang 7c50bccec2 nullish coalescing commit (#32883)
* 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
2019-09-30 15:33:50 -07:00

40 lines
874 B
TypeScript

// @noEmit: true
// @allowJs: true
// @checkJs: true
// @target: esnext
// @Filename: a.js
var my = my ?? {};
/** @param {number} n */
my.method = function(n) {
return n + 1;
}
my.number = 1;
my.object = {};
my.predicate = my.predicate ?? {};
my.predicate.query = function () {
var me = this;
me.property = false;
};
var q = new my.predicate.query();
my.predicate.query.another = function () {
return 1;
}
my.predicate.query.result = 'none'
/** @param {number} first
* @param {number} second
*/
my.predicate.sort = my.predicate.sort ?? function (first, second) {
return first > second ? first : second;
}
my.predicate.type = class {
m() { return 101; }
}
// global-ish prefixes
var min = window.min ?? {};
min.nest = this.min.nest ?? function () { };
min.nest.other = self.min.nest.other ?? class { };
min.property = global.min.property ?? {};