TypeScript/tests/cases/conformance/salsa/constructorFunctionMergeWithClass.ts
Nathan Shively-Sanders 8a4b6e03ab Fix class/constructor-function merge (#27366)
The check for prototype assignment on constructor functions assumes
that the prototype property, if present, comes from an assignment
declaration, such as:

```js
SomeClass.prototype = { /* methods go here */ }
```

In this case, however, when class SomeClass and var SomeClass merge
(because this is allowed), prototype is the synthetic property from
class SomeClass, which has no valueDeclaration.

The fix is to check that prototype has a valueDeclaration before
checking whether the valueDeclaration is in fact a prototype-assignment
declaration.
2018-10-08 12:56:19 -07:00

15 lines
215 B
TypeScript

// @allowJs: true
// @noEmit: true
// @checkJs: true
// @Filename: file1.js
var SomeClass = function () {
this.otherProp = 0;
};
new SomeClass();
// @Filename: file2.js
class SomeClass { }
SomeClass.prop = 0