mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-04 21:53:42 -06:00
Ensure functions that have prototype properties assigned by Object.defineProperty get marked as classes (#34577)
* Ensure functions that have prototype properties assigned by Object.defineProperty get marked as classes * Revert unneeded change
This commit is contained in:
parent
cdf1ab2dec
commit
91196fc53f
@ -2788,6 +2788,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);
|
||||
}
|
||||
|
||||
|
||||
@ -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))
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@ -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
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@ -0,0 +1,14 @@
|
||||
// @allowJs: true
|
||||
// @checkJs: false
|
||||
// @noEmit: true
|
||||
// @Filename: /a.js
|
||||
|
||||
function Graphic() {
|
||||
}
|
||||
|
||||
Object.defineProperty(Graphic.prototype, "instance", {
|
||||
get: function() {
|
||||
return this;
|
||||
}
|
||||
});
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user