File: typeFromPropertyAssignment28.types

package info (click to toggle)
node-typescript 3.3.3333-1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 324,548 kB
  • sloc: makefile: 6; sh: 3
file content (38 lines) | stat: -rw-r--r-- 765 bytes parent folder | download
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
31
32
33
34
35
36
37
38
=== tests/cases/conformance/salsa/a.js ===
// mixed prototype-assignment+class declaration
class C { constructor() { this.p = 1; } }
>C : C
>this.p = 1 : 1
>this.p : number
>this : this
>p : number
>1 : 1

// 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 = { q: 2 } : { q: number; }
>C.prototype : C
>C : typeof C
>prototype : C
>{ q: 2 } : { q: number; }
>q : number
>2 : 2

const c = new C()
>c : C
>new C() : C
>C : typeof C

c.p
>c.p : number
>c : C
>p : number

c.q
>c.q : any
>c : C
>q : any