TypeScript/tests/baselines/reference/extractFunction/extractFunction_VariableDeclaration_Writes_Let_Type.ts
Andrew Casey 2ea4cfe23b Insert a line break before a function at EOF if needed
This is a pre-existing issue that became more obvious after refining
trivia handling.
2017-10-12 14:19:36 -07:00

35 lines
599 B
TypeScript

// ==ORIGINAL==
function f() {
let a = 1;
/*[#|*/let x: number = 1;
a++;/*|]*/
a; x;
}
// ==SCOPE::Extract to inner function in function 'f'==
function f() {
let a = 1;
let x: number = /*RENAME*/newFunction();
a; x;
function newFunction() {
let x: number = 1;
a++;
return x;
}
}
// ==SCOPE::Extract to function in global scope==
function f() {
let a = 1;
let x: number | undefined;
({ x, a } = /*RENAME*/newFunction(a));
a; x;
}
function newFunction(a: number) {
let x: number = 1;
a++;
return { x, a };
}