TypeScript/tests/cases/fourslash/extract-method14.ts
2017-08-04 16:10:33 -07:00

24 lines
622 B
TypeScript

/// <reference path='fourslash.ts' />
// Don't emit type annotations in JavaScript files
// Also tests that single-variable return extractions don't get superfluous destructuring
// @allowNonTsExtensions: true
// @Filename: foo.js
//// function foo() {
//// var i = 10;
//// /*a*/return i++;/*b*/
//// }
goTo.select('a', 'b');
edit.applyRefactor('Extract Method', 'scope_1');
verify.currentFileContentIs(`function foo() {
var i = 10;
var __return: any;
({ __return, i } = newFunction(i));
return __return;
}
function newFunction(i) {
return { __return: i++, i };
}
`);