TypeScript/tests/cases/fourslash/refactorConvertToEs6Module_export_namedClassExpression.ts
Nathan Shively-Sanders cdfa63aa40
Fix exported type resolution in commonjs (#24495)
* Fix resolution of exported types in commonjs

It is fine to resolve the types of exported classes in ES6:

```js
export class C {
}
var c = new C()
```

But not for commonjs exported classes:

```js
module.exports.C = class {
}
var c = new C() // should error
```

Fixes #24492

* All jsdoc type aliases are available locally in commonjs modules

* Check that location isSourceFile before commonJsModuleIndicator
2018-05-30 14:12:38 -07:00

16 lines
411 B
TypeScript

/// <reference path='fourslash.ts' />
// @allowJs: true
// @target: esnext
// @Filename: /a.js
////exports.C = class E { static instance = new E(); }
////exports.D = class D { static instance = new D(); }
verify.codeFix({
description: "Convert to ES6 module",
newFileContent:
`export const C = class E { static instance = new E(); }
export class D { static instance = new D(); }`,
});