2017-08-05 01:10:33 +02:00
|
|
|
/// <reference path='fourslash.ts' />
|
|
|
|
|
|
|
|
// Extraction in the context of a contextual
|
|
|
|
// type needs to produce an explicit return type
|
|
|
|
// annotation in the extracted function
|
|
|
|
|
|
|
|
//// function f() {
|
2017-09-07 16:28:12 +02:00
|
|
|
//// var x: 1 | 2 | 3 = /*start*/1 + 1 === 2 ? 1 : 2/*end*/;
|
2017-08-05 01:10:33 +02:00
|
|
|
//// }
|
|
|
|
|
|
|
|
goTo.select('start', 'end');
|
2017-08-25 18:53:28 +02:00
|
|
|
edit.applyRefactor({
|
2017-09-15 01:04:44 +02:00
|
|
|
refactorName: "Extract Symbol",
|
|
|
|
actionName: "function_scope_0",
|
2017-09-09 14:52:52 +02:00
|
|
|
actionDescription: "Extract to inner function in function 'f'",
|
2017-09-13 18:02:10 +02:00
|
|
|
newContent:
|
2017-08-05 01:10:33 +02:00
|
|
|
`function f() {
|
2017-09-13 18:02:10 +02:00
|
|
|
var x: 1 | 2 | 3 = /*RENAME*/newFunction();
|
2017-08-05 01:10:33 +02:00
|
|
|
|
|
|
|
function newFunction(): 1 | 2 | 3 {
|
2017-09-07 23:30:19 +02:00
|
|
|
return 1 + 1 === 2 ? 1 : 2;
|
2017-08-05 01:10:33 +02:00
|
|
|
}
|
2017-09-13 18:02:10 +02:00
|
|
|
}`
|
|
|
|
});
|