TypeScript/tests/cases/conformance/salsa/typeFromPropertyAssignment28.ts
Nathan Shively-Sanders 50ef631b59
Support prototype assignment with a function declaration (#25300)
Previously variable declaration+function expression worked.
Note that class expression/class declaration do not work, due to the way
they are specified. I added a test for future reference.
2018-07-05 09:04:28 -07:00

16 lines
453 B
TypeScript

// @noEmit: true
// @allowJs: true
// @checkJs: true
// @Filename: a.js
// mixed prototype-assignment+class declaration
class C { constructor() { this.p = 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 };
const c = new C()
c.p
c.q