mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-30 01:04:49 -05:00
Don't treat object properties as potential JS contructors without JSDoc class tag (#49735)
This commit is contained in:
30
tests/cases/compiler/objectPropertyAsClass.ts
Normal file
30
tests/cases/compiler/objectPropertyAsClass.ts
Normal file
@@ -0,0 +1,30 @@
|
||||
// @allowJs: true
|
||||
// @noEmit: true
|
||||
// @checkJs: true
|
||||
|
||||
// @filename: index.js
|
||||
const a1 = {
|
||||
foo() {
|
||||
this.x = 0;
|
||||
}
|
||||
}
|
||||
|
||||
const a2 = {
|
||||
foo: function() {
|
||||
this.x = 0;
|
||||
}
|
||||
}
|
||||
|
||||
const b1 = {
|
||||
/** @class */
|
||||
foo() {
|
||||
this.x = 0;
|
||||
}
|
||||
}
|
||||
|
||||
const b2 = {
|
||||
/** @class */
|
||||
foo: function() {
|
||||
this.x = 0;
|
||||
}
|
||||
}
|
||||
21
tests/cases/compiler/thisInObjectJs.ts
Normal file
21
tests/cases/compiler/thisInObjectJs.ts
Normal file
@@ -0,0 +1,21 @@
|
||||
// @allowJs: true
|
||||
// @outDir: out
|
||||
|
||||
// @filename: index.js
|
||||
export { }
|
||||
let obj = {
|
||||
x: 10,
|
||||
y: [1],
|
||||
fun: function() {
|
||||
this.x = 1
|
||||
this/*1*/
|
||||
},
|
||||
f2: function() {
|
||||
this.x
|
||||
this/*2*/
|
||||
},
|
||||
f3: (function() {
|
||||
this.x = 1
|
||||
this/*3*/
|
||||
}),
|
||||
}
|
||||
Reference in New Issue
Block a user