TypeScript/tests/cases/fourslash/moveToNewFile_js.ts
Andrew Branch f9945f5acf
Full support for CommonJS auto-imports in JS (#37027)
* Support add new requires

* Always use destructuring for requiring default exports

* Add more tests

* Update existing fourslash tests

* Use `getExportsAndPropertiesOfModule`

* Add UMD test

* Apply suggestions from code review

Fix typos

Co-Authored-By: Nathan Shively-Sanders <293473+sandersn@users.noreply.github.com>

Co-authored-by: Nathan Shively-Sanders <293473+sandersn@users.noreply.github.com>
2020-02-28 14:34:20 -08:00

35 lines
619 B
TypeScript

/// <reference path='fourslash.ts' />
// @module: esnext
// @allowJs: true
// @Filename: /a.js
////const { a, b } = require("./other");
////const p = 0;
////[|const y = p + b;
////const z = 0;
////exports.z = 0;|]
////a; y; z;
// @Filename: /user.ts
////const { x, y } = require("./a");
verify.moveToNewFile({
newFileContents: {
"/a.js":
`const { a, } = require("./other");
const { y, z } = require("./y");
const p = 0;
exports.p = p;
a; y; z;`,
"/y.js":
`const { b } = require("./other");
const { p } = require("./a");
const y = p + b;
exports.y = y;
const z = 0;
exports.z = 0;
`,
},
});