mirror of
https://github.com/hanzoai/tsgo.git
synced 2026-10-30 19:37:15 +00:00
205 lines
7.9 KiB
Plaintext
205 lines
7.9 KiB
Plaintext
//// [tests/cases/conformance/jsdoc/checkObjectDefineProperty.ts] ////
|
|
|
|
=== validate.ts ===
|
|
// Validate in TS as simple validations would usually be interpreted as more special assignments
|
|
import x = require("./");
|
|
>x : Symbol(x, Decl(validate.ts, 0, 0))
|
|
|
|
x.name;
|
|
>x.name : Symbol("name", Decl(index.js, 0, 13))
|
|
>x : Symbol(x, Decl(validate.ts, 0, 0))
|
|
>name : Symbol("name", Decl(index.js, 0, 13))
|
|
|
|
x.middleInit;
|
|
>x.middleInit : Symbol("middleInit", Decl(index.js, 1, 71))
|
|
>x : Symbol(x, Decl(validate.ts, 0, 0))
|
|
>middleInit : Symbol("middleInit", Decl(index.js, 1, 71))
|
|
|
|
x.lastName;
|
|
>x.lastName : Symbol("lastName", Decl(index.js, 2, 55))
|
|
>x : Symbol(x, Decl(validate.ts, 0, 0))
|
|
>lastName : Symbol("lastName", Decl(index.js, 2, 55))
|
|
|
|
x.zip;
|
|
>x.zip : Symbol("zip", Decl(index.js, 3, 74))
|
|
>x : Symbol(x, Decl(validate.ts, 0, 0))
|
|
>zip : Symbol("zip", Decl(index.js, 3, 74))
|
|
|
|
x.houseNumber;
|
|
>x.houseNumber : Symbol("houseNumber", Decl(index.js, 4, 83))
|
|
>x : Symbol(x, Decl(validate.ts, 0, 0))
|
|
>houseNumber : Symbol("houseNumber", Decl(index.js, 4, 83))
|
|
|
|
x.zipStr;
|
|
>x.zipStr : Symbol("zipStr", Decl(index.js, 5, 68))
|
|
>x : Symbol(x, Decl(validate.ts, 0, 0))
|
|
>zipStr : Symbol("zipStr", Decl(index.js, 5, 68))
|
|
|
|
x.name = "Another";
|
|
>x.name : Symbol("name", Decl(index.js, 0, 13))
|
|
>x : Symbol(x, Decl(validate.ts, 0, 0))
|
|
>name : Symbol("name", Decl(index.js, 0, 13))
|
|
|
|
x.zip = 98123;
|
|
>x.zip : Symbol("zip", Decl(index.js, 3, 74))
|
|
>x : Symbol(x, Decl(validate.ts, 0, 0))
|
|
>zip : Symbol("zip", Decl(index.js, 3, 74))
|
|
|
|
x.zipStr = "OK";
|
|
>x.zipStr : Symbol("zipStr", Decl(index.js, 5, 68))
|
|
>x : Symbol(x, Decl(validate.ts, 0, 0))
|
|
>zipStr : Symbol("zipStr", Decl(index.js, 5, 68))
|
|
|
|
x.lastName = "should fail";
|
|
>x.lastName : Symbol("lastName", Decl(index.js, 2, 55))
|
|
>x : Symbol(x, Decl(validate.ts, 0, 0))
|
|
>lastName : Symbol("lastName", Decl(index.js, 2, 55))
|
|
|
|
x.houseNumber = 12; // should also fail
|
|
>x.houseNumber : Symbol("houseNumber", Decl(index.js, 4, 83))
|
|
>x : Symbol(x, Decl(validate.ts, 0, 0))
|
|
>houseNumber : Symbol("houseNumber", Decl(index.js, 4, 83))
|
|
|
|
x.zipStr = 12; // should fail
|
|
>x.zipStr : Symbol("zipStr", Decl(index.js, 5, 68))
|
|
>x : Symbol(x, Decl(validate.ts, 0, 0))
|
|
>zipStr : Symbol("zipStr", Decl(index.js, 5, 68))
|
|
|
|
x.middleInit = "R"; // should also fail
|
|
>x.middleInit : Symbol("middleInit", Decl(index.js, 1, 71))
|
|
>x : Symbol(x, Decl(validate.ts, 0, 0))
|
|
>middleInit : Symbol("middleInit", Decl(index.js, 1, 71))
|
|
|
|
=== index.js ===
|
|
const x = {};
|
|
>x : Symbol(x, Decl(index.js, 0, 5))
|
|
|
|
Object.defineProperty(x, "name", { value: "Charles", writable: true });
|
|
>Object.defineProperty : Symbol(ObjectConstructor.defineProperty, Decl(lib.es5.d.ts, --, --))
|
|
>Object : Symbol(Object, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --))
|
|
>defineProperty : Symbol(ObjectConstructor.defineProperty, Decl(lib.es5.d.ts, --, --))
|
|
>x : Symbol(x, Decl(index.js, 0, 5))
|
|
>"name" : Symbol("name", Decl(index.js, 0, 13))
|
|
>value : Symbol(value, Decl(index.js, 1, 34))
|
|
>writable : Symbol(writable, Decl(index.js, 1, 52))
|
|
|
|
Object.defineProperty(x, "middleInit", { value: "H" });
|
|
>Object.defineProperty : Symbol(ObjectConstructor.defineProperty, Decl(lib.es5.d.ts, --, --))
|
|
>Object : Symbol(Object, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --))
|
|
>defineProperty : Symbol(ObjectConstructor.defineProperty, Decl(lib.es5.d.ts, --, --))
|
|
>x : Symbol(x, Decl(index.js, 0, 5))
|
|
>"middleInit" : Symbol("middleInit", Decl(index.js, 1, 71))
|
|
>value : Symbol(value, Decl(index.js, 2, 40))
|
|
|
|
Object.defineProperty(x, "lastName", { value: "Smith", writable: false });
|
|
>Object.defineProperty : Symbol(ObjectConstructor.defineProperty, Decl(lib.es5.d.ts, --, --))
|
|
>Object : Symbol(Object, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --))
|
|
>defineProperty : Symbol(ObjectConstructor.defineProperty, Decl(lib.es5.d.ts, --, --))
|
|
>x : Symbol(x, Decl(index.js, 0, 5))
|
|
>"lastName" : Symbol("lastName", Decl(index.js, 2, 55))
|
|
>value : Symbol(value, Decl(index.js, 3, 38))
|
|
>writable : Symbol(writable, Decl(index.js, 3, 54))
|
|
|
|
Object.defineProperty(x, "zip", { get() { return 98122 }, set(_) { /*ignore*/ } });
|
|
>Object.defineProperty : Symbol(ObjectConstructor.defineProperty, Decl(lib.es5.d.ts, --, --))
|
|
>Object : Symbol(Object, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --))
|
|
>defineProperty : Symbol(ObjectConstructor.defineProperty, Decl(lib.es5.d.ts, --, --))
|
|
>x : Symbol(x, Decl(index.js, 0, 5))
|
|
>"zip" : Symbol("zip", Decl(index.js, 3, 74))
|
|
>get : Symbol(get, Decl(index.js, 4, 33))
|
|
>set : Symbol(set, Decl(index.js, 4, 57))
|
|
>_ : Symbol(_, Decl(index.js, 4, 62))
|
|
|
|
Object.defineProperty(x, "houseNumber", { get() { return 21.75 } });
|
|
>Object.defineProperty : Symbol(ObjectConstructor.defineProperty, Decl(lib.es5.d.ts, --, --))
|
|
>Object : Symbol(Object, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --))
|
|
>defineProperty : Symbol(ObjectConstructor.defineProperty, Decl(lib.es5.d.ts, --, --))
|
|
>x : Symbol(x, Decl(index.js, 0, 5))
|
|
>"houseNumber" : Symbol("houseNumber", Decl(index.js, 4, 83))
|
|
>get : Symbol(get, Decl(index.js, 5, 41))
|
|
|
|
Object.defineProperty(x, "zipStr", {
|
|
>Object.defineProperty : Symbol(ObjectConstructor.defineProperty, Decl(lib.es5.d.ts, --, --))
|
|
>Object : Symbol(Object, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --))
|
|
>defineProperty : Symbol(ObjectConstructor.defineProperty, Decl(lib.es5.d.ts, --, --))
|
|
>x : Symbol(x, Decl(index.js, 0, 5))
|
|
>"zipStr" : Symbol("zipStr", Decl(index.js, 5, 68))
|
|
|
|
/** @param {string} str */
|
|
set(str) {
|
|
>set : Symbol(set, Decl(index.js, 6, 36))
|
|
>str : Symbol(str, Decl(index.js, 8, 8))
|
|
|
|
this.zip = Number(str)
|
|
>Number : Symbol(Number, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --))
|
|
>str : Symbol(str, Decl(index.js, 8, 8))
|
|
}
|
|
});
|
|
|
|
/**
|
|
* @param {{name: string}} named
|
|
*/
|
|
function takeName(named) { return named.name; }
|
|
>takeName : Symbol(takeName, Decl(index.js, 11, 3))
|
|
>named : Symbol(named, Decl(index.js, 16, 18))
|
|
>named.name : Symbol(name, Decl(index.js, 14, 12))
|
|
>named : Symbol(named, Decl(index.js, 16, 18))
|
|
>name : Symbol(name, Decl(index.js, 14, 12))
|
|
|
|
takeName(x);
|
|
>takeName : Symbol(takeName, Decl(index.js, 11, 3))
|
|
>x : Symbol(x, Decl(index.js, 0, 5))
|
|
|
|
/**
|
|
* @type {number}
|
|
*/
|
|
var a = x.zip;
|
|
>a : Symbol(a, Decl(index.js, 22, 3))
|
|
>x.zip : Symbol("zip", Decl(index.js, 3, 74))
|
|
>x : Symbol(x, Decl(index.js, 0, 5))
|
|
>zip : Symbol("zip", Decl(index.js, 3, 74))
|
|
|
|
/**
|
|
* @type {number}
|
|
*/
|
|
var b = x.houseNumber;
|
|
>b : Symbol(b, Decl(index.js, 27, 3))
|
|
>x.houseNumber : Symbol("houseNumber", Decl(index.js, 4, 83))
|
|
>x : Symbol(x, Decl(index.js, 0, 5))
|
|
>houseNumber : Symbol("houseNumber", Decl(index.js, 4, 83))
|
|
|
|
const returnExemplar = () => x;
|
|
>returnExemplar : Symbol(returnExemplar, Decl(index.js, 29, 5))
|
|
>x : Symbol(x, Decl(index.js, 0, 5))
|
|
|
|
const needsExemplar = (_ = x) => void 0;
|
|
>needsExemplar : Symbol(needsExemplar, Decl(index.js, 30, 5))
|
|
>_ : Symbol(_, Decl(index.js, 30, 23))
|
|
>x : Symbol(x, Decl(index.js, 0, 5))
|
|
|
|
const expected = /** @type {{name: string, readonly middleInit: string, readonly lastName: string, zip: number, readonly houseNumber: number, zipStr: string}} */(/** @type {*} */(null));
|
|
>expected : Symbol(expected, Decl(index.js, 32, 5))
|
|
|
|
/**
|
|
*
|
|
* @param {typeof returnExemplar} a
|
|
* @param {typeof needsExemplar} b
|
|
*/
|
|
function match(a, b) {}
|
|
>match : Symbol(match, Decl(index.js, 32, 186))
|
|
>a : Symbol(a, Decl(index.js, 39, 15))
|
|
>b : Symbol(b, Decl(index.js, 39, 17))
|
|
|
|
match(() => expected, (x = expected) => void 0);
|
|
>match : Symbol(match, Decl(index.js, 32, 186))
|
|
>expected : Symbol(expected, Decl(index.js, 32, 5))
|
|
>x : Symbol(x, Decl(index.js, 41, 23))
|
|
>expected : Symbol(expected, Decl(index.js, 32, 5))
|
|
|
|
module.exports = x;
|
|
>module.exports : Symbol(exports, Decl(index.js, 0, 0))
|
|
>module : Symbol(module, Decl(index.js, 0, 0))
|
|
>exports : Symbol(exports, Decl(index.js, 0, 0))
|
|
>x : Symbol(x, Decl(index.js, 0, 5))
|
|
|