TypeScript/tests/baselines/reference/jsdocReadonly.types
Anders Hejlsberg 3919042c7f
Control flow for constructor initialized properties (#37920)
* Use CFA to determine types of properties declared by this.xxx assignments

* Accept new baselines

* Also use CFA in constructor functions

* Accept new baselines

* Fix lint error

* Only widen fresh literal types in CFA of assignment to auto-typed

* Auto-typing for declared properties with no type annotation or initializer

* Add optionality if declaration includes '?' modifier

* Always use CFA for properties with no initializer in .js files

* Small fix
2020-04-28 16:59:03 -07:00

57 lines
790 B
Plaintext

=== tests/cases/conformance/jsdoc/jsdocReadonly.js ===
class LOL {
>LOL : LOL
/**
* @readonly
* @private
* @type {number}
* Order rules do not apply to JSDoc
*/
x = 1
>x : number
>1 : 1
/** @readonly */
y = 2
>y : 2
>2 : 2
/** @readonly Definitely not here */
static z = 3
>z : 3
>3 : 3
/** @readonly This is OK too */
constructor() {
/** ok */
this.y = 2
>this.y = 2 : 2
>this.y : 2
>this : this
>y : 2
>2 : 2
/** @readonly ok */
this.ka = 2
>this.ka = 2 : 2
>this.ka : any
>this : this
>ka : any
>2 : 2
}
}
var l = new LOL()
>l : LOL
>new LOL() : LOL
>LOL : typeof LOL
l.y = 12
>l.y = 12 : 12
>l.y : any
>l : LOL
>y : any
>12 : 12