TypeScript/tests/cases/conformance/jsdoc/checkOtherObjectAssignProperty.ts
Wesley Wigham 69b1cb5bac
Add new special assignment kinds for recognizing Object.defineProperty calls (#27208)
* Add new special assignment kinds for recognizing Object.defineProperty calls

* Add support for prototype assignments, fix nits

* Fix code review comments

* Add test documenting behavior in a few more odd scenarios
2018-10-19 14:31:55 -07:00

40 lines
849 B
TypeScript

// @allowJs: true
// @noEmit: true
// @strict: true
// @checkJs: true
// @filename: mod1.js
const obj = { value: 42, writable: true };
Object.defineProperty(exports, "thing", obj);
/**
* @type {string}
*/
let str = /** @type {string} */("other");
Object.defineProperty(exports, str, { value: 42, writable: true });
const propName = "prop"
Object.defineProperty(exports, propName, { value: 42, writable: true });
Object.defineProperty(exports, "bad1", { });
Object.defineProperty(exports, "bad2", { get() { return 12 }, value: "no" });
Object.defineProperty(exports, "bad3", { writable: true });
// @filename: importer.js
const mod = require("./mod1");
mod.thing;
mod.other;
mod.prop;
mod.bad1;
mod.bad2;
mod.bad3;
mod.thing = 0;
mod.other = 0;
mod.prop = 0;
mod.bad1 = 0;
mod.bad2 = 0;
mod.bad3 = 0;