Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/compiler/binder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2789,6 +2789,10 @@ namespace ts {

function bindObjectDefinePrototypeProperty(node: BindableObjectDefinePropertyCall) {
const namespaceSymbol = lookupSymbolForPropertyAccess((node.arguments[0] as PropertyAccessExpression).expression as EntityNameExpression);
if (namespaceSymbol) {
// Ensure the namespace symbol becomes class-like
addDeclarationToSymbol(namespaceSymbol, namespaceSymbol.valueDeclaration, SymbolFlags.Class);
}
bindPotentiallyNewExpandoMemberToNamespace(node, namespaceSymbol, /*isPrototypeProperty*/ true);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
=== /a.js ===
function Graphic() {
>Graphic : Symbol(Graphic, Decl(a.js, 0, 0))
}

Object.defineProperty(Graphic.prototype, "instance", {
>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, --, --))
>Graphic.prototype : Symbol(Function.prototype, Decl(lib.es5.d.ts, --, --))
>Graphic : Symbol(Graphic, Decl(a.js, 0, 0))
>prototype : Symbol(Function.prototype, Decl(lib.es5.d.ts, --, --))
>"instance" : Symbol(Graphic.instance, Decl(a.js, 1, 1))

get: function() {
>get : Symbol(get, Decl(a.js, 3, 54))

return this;
>this : Symbol(Graphic, Decl(a.js, 0, 0))
}
});


Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
=== /a.js ===
function Graphic() {
>Graphic : typeof Graphic
}

Object.defineProperty(Graphic.prototype, "instance", {
>Object.defineProperty(Graphic.prototype, "instance", { get: function() { return this; }}) : any
>Object.defineProperty : (o: any, p: string | number | symbol, attributes: PropertyDescriptor & ThisType<any>) => any
>Object : ObjectConstructor
>defineProperty : (o: any, p: string | number | symbol, attributes: PropertyDescriptor & ThisType<any>) => any
>Graphic.prototype : any
>Graphic : typeof Graphic
>prototype : any
>"instance" : "instance"
>{ get: function() { return this; }} : { get: () => this; }

get: function() {
>get : () => this
>function() { return this; } : () => this

return this;
>this : this
}
});


Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// @allowJs: true
// @checkJs: false
// @noEmit: true
// @Filename: /a.js

function Graphic() {
}

Object.defineProperty(Graphic.prototype, "instance", {
get: function() {
return this;
}
});