1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62
|
/// <reference path="fourslash.ts" />
// @filename: /project/tsconfig.json
//// {}
// @filename: /project/index.esm.d.ts
//// export declare class Chart {
//// constructor(config: ChartConfiguration);
//// }
////
//// export interface ChartConfiguration {
//// options?: Partial<TickOptions>;
//// }
////
//// export interface TickOptions {
//// callback: (this: Scale, tickValue: number | string) => string | string[] | number | number[] | null | undefined;
//// }
////
//// export interface CoreScaleOptions {
//// opt: boolean;
//// }
////
//// export interface Scale<O extends CoreScaleOptions = CoreScaleOptions> {
//// opts: O;
//// getLabelForValue(value: number): string;
//// }
// @filename: /project/options.ts
//// import { Chart } from './index.esm';
////
//// const chart = new Chart({
//// options: {
//// callback(tickValue) {
//// /*a*/const value = this.getLabelForValue(tickValue as number);/*b*/
//// return '$' + value;
//// }
//// }
//// });
goTo.file("/project/options.ts");
verify.noErrors();
goTo.select("a", "b");
edit.applyRefactor({
refactorName: "Extract Symbol",
actionName: "function_scope_0",
actionDescription: "Extract to inner function in method 'callback'",
newContent:
`import { Chart } from './index.esm';
const chart = new Chart({
options: {
callback(tickValue) {
const value = /*RENAME*/newFunction.call(this);
return '$' + value;
function newFunction(this: import("/project/index.esm").Scale<import("/project/index.esm").CoreScaleOptions>) {
return this.getLabelForValue(tickValue as number);
}
}
}
});`
});
|