File: typeFromPropertyAssignment28.symbols

package info (click to toggle)
node-typescript 5.0.4%2Bds1-1
  • links: PTS, VCS
  • area: main
  • in suites: experimental
  • size: 459,116 kB
  • sloc: javascript: 1,972,754; makefile: 6; sh: 1
file content (30 lines) | stat: -rw-r--r-- 1,059 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
=== tests/cases/conformance/salsa/a.js ===
// mixed prototype-assignment+class declaration
class C { constructor() { this.p = 1; } }
>C : Symbol(C, Decl(a.js, 0, 0), Decl(a.js, 1, 41))
>this.p : Symbol(C.p, Decl(a.js, 1, 25))
>this : Symbol(C, Decl(a.js, 0, 0), Decl(a.js, 1, 41))
>p : Symbol(C.p, Decl(a.js, 1, 25))

// Property assignment does nothing.
// You have to use Object.defineProperty(C, "prototype", { q: 2 })
// and that only works on classes with no superclass.
// (Object.defineProperty isn't recognised as a JS special assignment right now.)
C.prototype = { q: 2 };
>C.prototype : Symbol(C.prototype, Decl(a.js, 1, 41))
>C : Symbol(C, Decl(a.js, 0, 0), Decl(a.js, 1, 41))
>prototype : Symbol(C.prototype, Decl(a.js, 1, 41))
>q : Symbol(q, Decl(a.js, 6, 15))

const c = new C()
>c : Symbol(c, Decl(a.js, 8, 5))
>C : Symbol(C, Decl(a.js, 0, 0), Decl(a.js, 1, 41))

c.p
>c.p : Symbol(C.p, Decl(a.js, 1, 25))
>c : Symbol(c, Decl(a.js, 8, 5))
>p : Symbol(C.p, Decl(a.js, 1, 25))

c.q
>c : Symbol(c, Decl(a.js, 8, 5))