Fix the third crash in the chrome user suite test by remembering to pass excludeThisKeyword (#33711)

This commit is contained in:
Wesley Wigham 2019-10-01 13:14:23 -07:00 committed by GitHub
parent 20f42f45ff
commit 410ff90c54
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 77 additions and 1 deletions

View file

@ -2060,7 +2060,7 @@ namespace ts {
idText(expr.expression.expression) === "Object" &&
idText(expr.expression.name) === "defineProperty" &&
isStringOrNumericLiteralLike(expr.arguments[1]) &&
isBindableStaticNameExpression(expr.arguments[0]);
isBindableStaticNameExpression(expr.arguments[0], /*excludeThisKeyword*/ true);
}
export function isBindableStaticElementAccessExpression(node: Node, excludeThisKeyword?: boolean): node is BindableStaticElementAccessExpression {

View file

@ -0,0 +1,13 @@
tests/cases/compiler/jsCheckObjectDefineThisNoCrash.js(5,36): error TS2339: Property '_prop' does not exist on type 'C'.
==== tests/cases/compiler/jsCheckObjectDefineThisNoCrash.js (1 errors) ====
class C {
constructor() {
// Neither of the following should be recognized as declarations yet
Object.defineProperty(this, "_prop", { value: {} });
Object.defineProperty(this._prop, "num", { value: 12 });
~~~~~
!!! error TS2339: Property '_prop' does not exist on type 'C'.
}
}

View file

@ -0,0 +1,21 @@
=== tests/cases/compiler/jsCheckObjectDefineThisNoCrash.js ===
class C {
>C : Symbol(C, Decl(jsCheckObjectDefineThisNoCrash.js, 0, 0))
constructor() {
// Neither of the following should be recognized as declarations yet
Object.defineProperty(this, "_prop", { value: {} });
>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, --, --))
>this : Symbol(C, Decl(jsCheckObjectDefineThisNoCrash.js, 0, 0))
>value : Symbol(value, Decl(jsCheckObjectDefineThisNoCrash.js, 3, 46))
Object.defineProperty(this._prop, "num", { value: 12 });
>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, --, --))
>this : Symbol(C, Decl(jsCheckObjectDefineThisNoCrash.js, 0, 0))
>value : Symbol(value, Decl(jsCheckObjectDefineThisNoCrash.js, 4, 50))
}
}

View file

@ -0,0 +1,31 @@
=== tests/cases/compiler/jsCheckObjectDefineThisNoCrash.js ===
class C {
>C : C
constructor() {
// Neither of the following should be recognized as declarations yet
Object.defineProperty(this, "_prop", { value: {} });
>Object.defineProperty(this, "_prop", { value: {} }) : 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
>this : this
>"_prop" : "_prop"
>{ value: {} } : { value: {}; }
>value : {}
>{} : {}
Object.defineProperty(this._prop, "num", { value: 12 });
>Object.defineProperty(this._prop, "num", { value: 12 }) : 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
>this._prop : any
>this : this
>_prop : any
>"num" : "num"
>{ value: 12 } : { value: number; }
>value : number
>12 : 12
}
}

View file

@ -0,0 +1,11 @@
// @checkJs: true
// @allowJs: true
// @noEmit: true
// @filename: jsCheckObjectDefineThisNoCrash.js
class C {
constructor() {
// Neither of the following should be recognized as declarations yet
Object.defineProperty(this, "_prop", { value: {} });
Object.defineProperty(this._prop, "num", { value: 12 });
}
}