Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 1, 2019
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
2 changes: 1 addition & 1 deletion src/compiler/utilities.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
@@ -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'.
}
}
21 changes: 21 additions & 0 deletions tests/baselines/reference/jsCheckObjectDefineThisNoCrash.symbols
Original file line number Diff line number Diff line change
@@ -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))
}
}
31 changes: 31 additions & 0 deletions tests/baselines/reference/jsCheckObjectDefineThisNoCrash.types
Original file line number Diff line number Diff line change
@@ -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
}
}
11 changes: 11 additions & 0 deletions tests/cases/compiler/jsCheckObjectDefineThisNoCrash.ts
Original file line number Diff line number Diff line change
@@ -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 });
}
}