From 12d736f0a42712c67907b47556d8d6bff97f8be9 Mon Sep 17 00:00:00 2001 From: Sheetal Nandi Date: Wed, 13 Mar 2019 14:25:43 -0700 Subject: [PATCH 1/7] Fix completions when writing spread expression Fixes #29234 --- src/services/completions.ts | 8 ++++++++ .../fourslash/completionsWritingSpreadArgument.ts | 12 ++++++++++++ 2 files changed, 20 insertions(+) create mode 100644 tests/cases/fourslash/completionsWritingSpreadArgument.ts diff --git a/src/services/completions.ts b/src/services/completions.ts index a070bf8f7c1..4c1b3db1af9 100644 --- a/src/services/completions.ts +++ b/src/services/completions.ts @@ -703,6 +703,14 @@ namespace ts.Completions { case SyntaxKind.PropertyAccessExpression: propertyAccessToConvert = parent as PropertyAccessExpression; node = propertyAccessToConvert.expression; + if (node.end === contextToken.pos && + isCallExpression(node) && + node.getChildCount(sourceFile) && + last(node.getChildren(sourceFile)).kind !== SyntaxKind.CloseParenToken) { + // This is likely dot from incorrectly parsed call expression and user is starting to write spread + // eg: Math.min(./**/) + return undefined; + } break; case SyntaxKind.QualifiedName: node = (parent as QualifiedName).left; diff --git a/tests/cases/fourslash/completionsWritingSpreadArgument.ts b/tests/cases/fourslash/completionsWritingSpreadArgument.ts new file mode 100644 index 00000000000..5fd4eaad179 --- /dev/null +++ b/tests/cases/fourslash/completionsWritingSpreadArgument.ts @@ -0,0 +1,12 @@ +/// + +//// +//// const [] = [Math.min(./*marker*/)] +//// + +goTo.marker("marker"); +verify.completions({ exact: undefined }); +edit.insert("."); +verify.completions({ exact: undefined }); +edit.insert("."); +verify.completions({ exact: completion.globals }); From c130fde79e1d8305bc13a920891438a749eab56c Mon Sep 17 00:00:00 2001 From: Gabriela Araujo Britto Date: Wed, 13 Mar 2019 15:10:54 -0700 Subject: [PATCH 2/7] fix check for default export --- src/services/findAllReferences.ts | 4 +++- src/services/importTracker.ts | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/services/findAllReferences.ts b/src/services/findAllReferences.ts index f96c53ee200..ef6a344c992 100644 --- a/src/services/findAllReferences.ts +++ b/src/services/findAllReferences.ts @@ -1196,7 +1196,9 @@ namespace ts.FindAllReferences.Core { // For `export { foo as bar }`, rename `foo`, but not `bar`. if (!isForRenameWithPrefixAndSuffixText(state.options) || alwaysGetReferences) { - const exportKind = referenceLocation.originalKeywordKind === SyntaxKind.DefaultKeyword ? ExportKind.Default : ExportKind.Named; + const isDefaultExport = referenceLocation.originalKeywordKind === SyntaxKind.DefaultKeyword + || exportSpecifier.name.originalKeywordKind === SyntaxKind.DefaultKeyword; + const exportKind = isDefaultExport ? ExportKind.Default : ExportKind.Named; const exportSymbol = Debug.assertDefined(exportSpecifier.symbol); const exportInfo = Debug.assertDefined(getExportInfo(exportSymbol, exportKind, state.checker)); searchForImportsOfExport(referenceLocation, exportSymbol, exportInfo, state); diff --git a/src/services/importTracker.ts b/src/services/importTracker.ts index 6b50d62d9b4..e8512528af9 100644 --- a/src/services/importTracker.ts +++ b/src/services/importTracker.ts @@ -269,7 +269,7 @@ namespace ts.FindAllReferences { } /** - * `import x = require("./x") or `import * as x from "./x"`. + * `import x = require("./x")` or `import * as x from "./x"`. * An `export =` may be imported by this syntax, so it may be a direct import. * If it's not a direct import, it will be in `indirectUsers`, so we don't have to do anything here. */ From 66e2c54fe532f34b8e5a41f406deed32a16ae23c Mon Sep 17 00:00:00 2001 From: Gabriela Araujo Britto Date: Wed, 13 Mar 2019 15:11:33 -0700 Subject: [PATCH 3/7] add tests for finding references of named and default exports --- .../fourslash/findAllRefsImportDefault.ts | 18 ++++++++++++++++++ .../cases/fourslash/findAllRefsImportNamed.ts | 15 +++++++++++++++ 2 files changed, 33 insertions(+) create mode 100644 tests/cases/fourslash/findAllRefsImportDefault.ts create mode 100644 tests/cases/fourslash/findAllRefsImportNamed.ts diff --git a/tests/cases/fourslash/findAllRefsImportDefault.ts b/tests/cases/fourslash/findAllRefsImportDefault.ts new file mode 100644 index 00000000000..15b3bda8ddf --- /dev/null +++ b/tests/cases/fourslash/findAllRefsImportDefault.ts @@ -0,0 +1,18 @@ +/// + +// @Filename: f.ts +////export { [|foo|] as [|{| "isWriteAccess": true, "isDefinition": true |}default|] }; +////function /*start*/[|{| "isWriteAccess": true, "isDefinition": true |}foo|](a: number, b: number) { +//// return a + b; +////} + +// @Filename: b.ts +////import [|{| "isWriteAccess": true, "isDefinition": true |}bar|] from "./f"; +////[|bar|](1, 2); + +verify.noErrors(); +const [ foo0, foo1, foo2, bar0, bar1 ] = test.ranges(); +const fooGroup = { definition: "function foo(a: number, b: number): number", ranges: [foo0, foo2] }; +const exportDefaultGroup = { definition: "(alias) function foo(a: number, b: number): number\nexport default", ranges: [foo1] }; +const barGroup = { definition: "(alias) function bar(a: number, b: number): number\nimport bar", ranges: [bar0, bar1]}; +verify.referenceGroups("start", [fooGroup, exportDefaultGroup, barGroup]); diff --git a/tests/cases/fourslash/findAllRefsImportNamed.ts b/tests/cases/fourslash/findAllRefsImportNamed.ts new file mode 100644 index 00000000000..5d18a8de164 --- /dev/null +++ b/tests/cases/fourslash/findAllRefsImportNamed.ts @@ -0,0 +1,15 @@ +/// + +// @Filename: f.ts +////export { [|foo|] as [|{| "isWriteAccess": true, "isDefinition": true |}foo|] } +////function /*start*/[|{| "isWriteAccess": true, "isDefinition": true |}foo|](a: number, b: number) { } + +// @Filename: b.ts +////import x = require("./f"); +////x.[|foo|](1, 2); + +verify.noErrors(); +const [ foo0, foo1, foo2, foo3 ] = test.ranges(); +const fooGroup = { definition: "function foo(a: number, b: number): void", ranges: [foo0, foo2] }; +const exportFooGroup = { definition: "(alias) function foo(a: number, b: number): void\nexport foo", ranges: [foo1, foo3] }; +verify.referenceGroups("start", [fooGroup, exportFooGroup]); From a571e501433c36e401f9da9cf48d789b7d099546 Mon Sep 17 00:00:00 2001 From: Sheetal Nandi Date: Thu, 14 Mar 2019 11:54:47 -0700 Subject: [PATCH 4/7] Use EmitAndSemanticDiagnosticsBuilder in builder from tsc --- src/compiler/tsbuild.ts | 4 ++-- src/compiler/watch.ts | 2 +- src/tsc/tsc.ts | 5 +++-- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/compiler/tsbuild.ts b/src/compiler/tsbuild.ts index 3e2c7c0f241..e9b4dacc7c4 100644 --- a/src/compiler/tsbuild.ts +++ b/src/compiler/tsbuild.ts @@ -347,13 +347,13 @@ namespace ts { return host; } - export function createSolutionBuilderHost(system = sys, createProgram?: CreateProgram, reportDiagnostic?: DiagnosticReporter, reportSolutionBuilderStatus?: DiagnosticReporter, reportErrorSummary?: ReportEmitErrorSummary) { + export function createSolutionBuilderHost(system = sys, createProgram?: CreateProgram, reportDiagnostic?: DiagnosticReporter, reportSolutionBuilderStatus?: DiagnosticReporter, reportErrorSummary?: ReportEmitErrorSummary) { const host = createSolutionBuilderHostBase(system, createProgram, reportDiagnostic, reportSolutionBuilderStatus) as SolutionBuilderHost; host.reportErrorSummary = reportErrorSummary; return host; } - export function createSolutionBuilderWithWatchHost(system = sys, createProgram?: CreateProgram, reportDiagnostic?: DiagnosticReporter, reportSolutionBuilderStatus?: DiagnosticReporter, reportWatchStatus?: WatchStatusReporter) { + export function createSolutionBuilderWithWatchHost(system = sys, createProgram?: CreateProgram, reportDiagnostic?: DiagnosticReporter, reportSolutionBuilderStatus?: DiagnosticReporter, reportWatchStatus?: WatchStatusReporter) { const host = createSolutionBuilderHostBase(system, createProgram, reportDiagnostic, reportSolutionBuilderStatus) as SolutionBuilderWithWatchHost; const watchHost = createWatchHost(system, reportWatchStatus); copyProperties(host, watchHost); diff --git a/src/compiler/watch.ts b/src/compiler/watch.ts index 1ad73c19382..8a94393e2ce 100644 --- a/src/compiler/watch.ts +++ b/src/compiler/watch.ts @@ -290,7 +290,7 @@ namespace ts { /** * Creates the watch compiler host that can be extended with config file or root file names and options host */ - export function createProgramHost(system: System, createProgram: CreateProgram | undefined): ProgramHost { + export function createProgramHost(system: System, createProgram: CreateProgram | undefined): ProgramHost { const getDefaultLibLocation = memoize(() => getDirectoryPath(normalizePath(system.getExecutingFilePath()))); let host: DirectoryStructureHost = system; host; // tslint:disable-line no-unused-expression (TODO: `host` is unused!) diff --git a/src/tsc/tsc.ts b/src/tsc/tsc.ts index d53d5bd3bd6..b5624b07ec1 100644 --- a/src/tsc/tsc.ts +++ b/src/tsc/tsc.ts @@ -207,9 +207,10 @@ namespace ts { reportWatchModeWithoutSysSupport(); } + // Use default createProgram const buildHost = buildOptions.watch ? - createSolutionBuilderWithWatchHost(sys, createEmitAndSemanticDiagnosticsBuilderProgram, reportDiagnostic, createBuilderStatusReporter(sys, shouldBePretty()), createWatchStatusReporter()) : - createSolutionBuilderHost(sys, createAbstractBuilder, reportDiagnostic, createBuilderStatusReporter(sys, shouldBePretty()), createReportErrorSummary(buildOptions)); + createSolutionBuilderWithWatchHost(sys, /*createProgram*/ undefined, reportDiagnostic, createBuilderStatusReporter(sys, shouldBePretty()), createWatchStatusReporter()) : + createSolutionBuilderHost(sys, /*createProgram*/ undefined, reportDiagnostic, createBuilderStatusReporter(sys, shouldBePretty()), createReportErrorSummary(buildOptions)); updateCreateProgram(buildHost); buildHost.afterProgramEmitAndDiagnostics = (program: BuilderProgram) => reportStatistics(program.getProgram()); From b67f6ec7100b2c50f120723b1d1597125baa92dc Mon Sep 17 00:00:00 2001 From: Sheetal Nandi Date: Thu, 14 Mar 2019 13:18:06 -0700 Subject: [PATCH 5/7] Display actual and expected diagnostic messages when they dont match --- src/harness/fakes.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/harness/fakes.ts b/src/harness/fakes.ts index 57e3722f64d..dcc125698c8 100644 --- a/src/harness/fakes.ts +++ b/src/harness/fakes.ts @@ -476,7 +476,9 @@ namespace fakes { assertDiagnosticMessages(...expectedDiagnostics: ExpectedDiagnostic[]) { const actual = this.diagnostics.slice().map(d => d.messageText as string); const expected = expectedDiagnostics.map(expectedDiagnosticToText); - assert.deepEqual(actual, expected, "Diagnostic arrays did not match"); + assert.deepEqual(actual, expected, `Diagnostic arrays did not match: +Actual: ${JSON.stringify(actual, /*replacer*/ undefined, " ")} +Expected: ${JSON.stringify(expected, /*replacer*/ undefined, " ")}`); } printDiagnostics(header = "== Diagnostics ==") { From 1c8a359914929e3969cebe27b89ac7369488dbdc Mon Sep 17 00:00:00 2001 From: Gabriela Britto Date: Thu, 14 Mar 2019 13:41:29 -0700 Subject: [PATCH 6/7] rename convert to named parameters (#30401) --- src/compiler/diagnosticMessages.json | 2 +- ...eters.ts => convertParamsToDestructuredObject.ts} | 6 +++--- src/services/tsconfig.json | 2 +- ...tParamsToDestructuredObject_allParamsOptional.ts} | 6 +++--- ...nvertParamsToDestructuredObject_arrowFunction.ts} | 6 +++--- ...amsToDestructuredObject_arrowFunctionWithType.ts} | 2 +- ...onvertParamsToDestructuredObject_callComments.ts} | 6 +++--- ...nvertParamsToDestructuredObject_callComments2.ts} | 6 +++--- ...ConvertParamsToDestructuredObject_chainedCall.ts} | 6 +++--- ...ToDestructuredObject_classDeclarationAliasing.ts} | 6 +++--- ...DestructuredObject_classDeclarationGoodUsages.ts} | 6 +++--- ...ertParamsToDestructuredObject_classExpression.ts} | 6 +++--- ...oDestructuredObject_classExpressionGoodUsages.ts} | 6 +++--- ...sToDestructuredObject_classExpressionHeritage.ts} | 6 +++--- ...aramsToDestructuredObject_classTypeParameters.ts} | 6 +++--- ...ConvertParamsToDestructuredObject_constructor.ts} | 6 +++--- ...onvertParamsToDestructuredObject_defaultClass.ts} | 2 +- ...torConvertParamsToDestructuredObject_function.ts} | 6 +++--- ...rtParamsToDestructuredObject_functionComments.ts} | 6 +++--- ...tParamsToDestructuredObject_functionComments1.ts} | 6 +++--- ...tParamsToDestructuredObject_functionComments2.ts} | 6 +++--- ...ParamsToDestructuredObject_functionExpression.ts} | 6 +++--- ...msToDestructuredObject_functionTypeParameters.ts} | 6 +++--- ...ramsToDestructuredObject_inheritedConstructor.ts} | 6 +++--- ...ertParamsToDestructuredObject_inheritedMethod.ts} | 6 +++--- ...ConvertParamsToDestructuredObject_initializer.ts} | 6 +++--- ...ramsToDestructuredObject_initializerInference.ts} | 6 +++--- ...actorConvertParamsToDestructuredObject_method.ts} | 6 +++--- ...ertParamsToDestructuredObject_methodCallUnion.ts} | 6 +++--- ...ConvertParamsToDestructuredObject_methodCalls.ts} | 6 +++--- ...ertParamsToDestructuredObject_methodOverrides.ts} | 12 ++++++------ ...orConvertParamsToDestructuredObject_overloads.ts} | 2 +- ...vertParamsToDestructuredObject_paramDecorator.ts} | 2 +- ...tParamsToDestructuredObject_recursiveFunction.ts} | 6 +++--- ...ParamsToDestructuredObject_restParamInference.ts} | 6 +++--- ...onvertParamsToDestructuredObject_staticMethod.ts} | 6 +++--- ...orConvertParamsToDestructuredObject_superCall.ts} | 6 +++--- ...orConvertParamsToDestructuredObject_thisParam.ts} | 6 +++--- ...vertParamsToDestructuredObject_typedRestParam.ts} | 6 +++--- ...rtParamsToDestructuredObject_varArrowFunction.ts} | 2 +- 40 files changed, 109 insertions(+), 109 deletions(-) rename src/services/refactors/{convertToNamedParameters.ts => convertParamsToDestructuredObject.ts} (97%) rename tests/cases/fourslash/{refactorConvertToNamedParameters_allParamsOptional.ts => refactorConvertParamsToDestructuredObject_allParamsOptional.ts} (58%) rename tests/cases/fourslash/{refactorConvertToNamedParameters_arrowFunction.ts => refactorConvertParamsToDestructuredObject_arrowFunction.ts} (55%) rename tests/cases/fourslash/{refactorConvertToNamedParameters_arrowFunctionWithContextualType.ts => refactorConvertParamsToDestructuredObject_arrowFunctionWithType.ts} (67%) rename tests/cases/fourslash/{refactorConvertToNamedParameters_callComments.ts => refactorConvertParamsToDestructuredObject_callComments.ts} (69%) rename tests/cases/fourslash/{refactorConvertToNamedParameters_callComments2.ts => refactorConvertParamsToDestructuredObject_callComments2.ts} (74%) rename tests/cases/fourslash/{refactorConvertToNamedParameters_chainedCall.ts => refactorConvertParamsToDestructuredObject_chainedCall.ts} (62%) rename tests/cases/fourslash/{refactorConvertToNamedParameters_classDeclarationAliasing.ts => refactorConvertParamsToDestructuredObject_classDeclarationAliasing.ts} (65%) rename tests/cases/fourslash/{refactorConvertToNamedParameters_classDeclarationGoodUsages.ts => refactorConvertParamsToDestructuredObject_classDeclarationGoodUsages.ts} (73%) rename tests/cases/fourslash/{refactorConvertToNamedParameters_classExpression.ts => refactorConvertParamsToDestructuredObject_classExpression.ts} (61%) rename tests/cases/fourslash/{refactorConvertToNamedParameters_classExpressionGoodUsages.ts => refactorConvertParamsToDestructuredObject_classExpressionGoodUsages.ts} (67%) rename tests/cases/fourslash/{refactorConvertToNamedParameters_classExpressionHeritage.ts => refactorConvertParamsToDestructuredObject_classExpressionHeritage.ts} (68%) rename tests/cases/fourslash/{refactorConvertToNamedParameters_classTypeParameters.ts => refactorConvertParamsToDestructuredObject_classTypeParameters.ts} (63%) rename tests/cases/fourslash/{refactorConvertToNamedParameters_constructor.ts => refactorConvertParamsToDestructuredObject_constructor.ts} (69%) rename tests/cases/fourslash/{refactorConvertToNamedParameters_defaultClass.ts => refactorConvertParamsToDestructuredObject_defaultClass.ts} (65%) rename tests/cases/fourslash/{refactorConvertToNamedParameters_function.ts => refactorConvertParamsToDestructuredObject_function.ts} (58%) rename tests/cases/fourslash/{refactorConvertToNamedParameters_functionComments.ts => refactorConvertParamsToDestructuredObject_functionComments.ts} (76%) rename tests/cases/fourslash/{refactorConvertToNamedParameters_functionComments1.ts => refactorConvertParamsToDestructuredObject_functionComments1.ts} (58%) rename tests/cases/fourslash/{refactorConvertToNamedParameters_functionComments2.ts => refactorConvertParamsToDestructuredObject_functionComments2.ts} (63%) rename tests/cases/fourslash/{refactorConvertToNamedParameters_functionExpression.ts => refactorConvertParamsToDestructuredObject_functionExpression.ts} (56%) rename tests/cases/fourslash/{refactorConvertToNamedParameters_functionTypeParameters.ts => refactorConvertParamsToDestructuredObject_functionTypeParameters.ts} (57%) rename tests/cases/fourslash/{refactorConvertToNamedParameters_inheritedConstructor.ts => refactorConvertParamsToDestructuredObject_inheritedConstructor.ts} (73%) rename tests/cases/fourslash/{refactorConvertToNamedParameters_inheritedMethod.ts => refactorConvertParamsToDestructuredObject_inheritedMethod.ts} (68%) rename tests/cases/fourslash/{refactorConvertToNamedParameters_initializer.ts => refactorConvertParamsToDestructuredObject_initializer.ts} (59%) rename tests/cases/fourslash/{refactorConvertToNamedParameters_initializerInference.ts => refactorConvertParamsToDestructuredObject_initializerInference.ts} (62%) rename tests/cases/fourslash/{refactorConvertToNamedParameters_method.ts => refactorConvertParamsToDestructuredObject_method.ts} (65%) rename tests/cases/fourslash/{refactorConvertToNamedParameters_methodCallUnion.ts => refactorConvertParamsToDestructuredObject_methodCallUnion.ts} (70%) rename tests/cases/fourslash/{refactorConvertToNamedParameters_methodCalls.ts => refactorConvertParamsToDestructuredObject_methodCalls.ts} (68%) rename tests/cases/fourslash/{refactorConvertToNamedParameters_methodOverrides.ts => refactorConvertParamsToDestructuredObject_methodOverrides.ts} (62%) rename tests/cases/fourslash/{refactorConvertToNamedParameters_overloads.ts => refactorConvertParamsToDestructuredObject_overloads.ts} (68%) rename tests/cases/fourslash/{refactorConvertToNamedParameters_paramDecorator.ts => refactorConvertParamsToDestructuredObject_paramDecorator.ts} (75%) rename tests/cases/fourslash/{refactorConvertToNamedParameters_recursiveFunction.ts => refactorConvertParamsToDestructuredObject_recursiveFunction.ts} (64%) rename tests/cases/fourslash/{refactorConvertToNamedParameters_restParamInference.ts => refactorConvertParamsToDestructuredObject_restParamInference.ts} (64%) rename tests/cases/fourslash/{refactorConvertToNamedParameters_staticMethod.ts => refactorConvertParamsToDestructuredObject_staticMethod.ts} (64%) rename tests/cases/fourslash/{refactorConvertToNamedParameters_superCall.ts => refactorConvertParamsToDestructuredObject_superCall.ts} (69%) rename tests/cases/fourslash/{refactorConvertToNamedParameters_thisParam.ts => refactorConvertParamsToDestructuredObject_thisParam.ts} (60%) rename tests/cases/fourslash/{refactorConvertToNamedParameters_typedRestParam.ts => refactorConvertParamsToDestructuredObject_typedRestParam.ts} (75%) rename tests/cases/fourslash/{refactorConvertToNamedParameters_varArrowFunction.ts => refactorConvertParamsToDestructuredObject_varArrowFunction.ts} (61%) diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index 5ef209b0a88..9ae3e1ca77e 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -4927,7 +4927,7 @@ "category": "Message", "code": 95074 }, - "Convert to named parameters": { + "Convert parameters to destructured object": { "category": "Message", "code": 95075 } diff --git a/src/services/refactors/convertToNamedParameters.ts b/src/services/refactors/convertParamsToDestructuredObject.ts similarity index 97% rename from src/services/refactors/convertToNamedParameters.ts rename to src/services/refactors/convertParamsToDestructuredObject.ts index 61e9ccf9811..f813f8ef768 100644 --- a/src/services/refactors/convertToNamedParameters.ts +++ b/src/services/refactors/convertParamsToDestructuredObject.ts @@ -1,6 +1,6 @@ /* @internal */ -namespace ts.refactor.convertToNamedParameters { - const refactorName = "Convert to named parameters"; +namespace ts.refactor.convertParamsToDestructuredObject { + const refactorName = "Convert parameters to destructured object"; const minimumParameterLength = 2; registerRefactor(refactorName, { getEditsForAction, getAvailableActions }); @@ -12,7 +12,7 @@ namespace ts.refactor.convertToNamedParameters { const functionDeclaration = getFunctionDeclarationAtPosition(file, startPosition, context.program.getTypeChecker()); if (!functionDeclaration) return emptyArray; - const description = getLocaleSpecificMessage(Diagnostics.Convert_to_named_parameters); + const description = getLocaleSpecificMessage(Diagnostics.Convert_parameters_to_destructured_object); return [{ name: refactorName, description, diff --git a/src/services/tsconfig.json b/src/services/tsconfig.json index 793089e62c8..e3f2358be10 100644 --- a/src/services/tsconfig.json +++ b/src/services/tsconfig.json @@ -84,7 +84,7 @@ "refactors/generateGetAccessorAndSetAccessor.ts", "refactors/moveToNewFile.ts", "refactors/addOrRemoveBracesToArrowFunction.ts", - "refactors/convertToNamedParameters.ts", + "refactors/convertParamsToDestructuredObject.ts", "services.ts", "breakpoints.ts", "transform.ts", diff --git a/tests/cases/fourslash/refactorConvertToNamedParameters_allParamsOptional.ts b/tests/cases/fourslash/refactorConvertParamsToDestructuredObject_allParamsOptional.ts similarity index 58% rename from tests/cases/fourslash/refactorConvertToNamedParameters_allParamsOptional.ts rename to tests/cases/fourslash/refactorConvertParamsToDestructuredObject_allParamsOptional.ts index 825b34c303d..8d8db719608 100644 --- a/tests/cases/fourslash/refactorConvertToNamedParameters_allParamsOptional.ts +++ b/tests/cases/fourslash/refactorConvertParamsToDestructuredObject_allParamsOptional.ts @@ -7,9 +7,9 @@ goTo.select("a", "b"); edit.applyRefactor({ - refactorName: "Convert to named parameters", - actionName: "Convert to named parameters", - actionDescription: "Convert to named parameters", + refactorName: "Convert parameters to destructured object", + actionName: "Convert parameters to destructured object", + actionDescription: "Convert parameters to destructured object", newContent: `function f({ a, b = "1" }: { a?: number; b?: string; } = {}): string { return b; } diff --git a/tests/cases/fourslash/refactorConvertToNamedParameters_arrowFunction.ts b/tests/cases/fourslash/refactorConvertParamsToDestructuredObject_arrowFunction.ts similarity index 55% rename from tests/cases/fourslash/refactorConvertToNamedParameters_arrowFunction.ts rename to tests/cases/fourslash/refactorConvertParamsToDestructuredObject_arrowFunction.ts index 6a5a8e328a5..97d337d8d1a 100644 --- a/tests/cases/fourslash/refactorConvertToNamedParameters_arrowFunction.ts +++ b/tests/cases/fourslash/refactorConvertParamsToDestructuredObject_arrowFunction.ts @@ -5,9 +5,9 @@ goTo.select("a", "b"); edit.applyRefactor({ - refactorName: "Convert to named parameters", - actionName: "Convert to named parameters", - actionDescription: "Convert to named parameters", + refactorName: "Convert parameters to destructured object", + actionName: "Convert parameters to destructured object", + actionDescription: "Convert parameters to destructured object", newContent: `const foo = ({ a, b }: { a: number; b: number; }) => { }; foo({ a: 1, b: 2 });` }); \ No newline at end of file diff --git a/tests/cases/fourslash/refactorConvertToNamedParameters_arrowFunctionWithContextualType.ts b/tests/cases/fourslash/refactorConvertParamsToDestructuredObject_arrowFunctionWithType.ts similarity index 67% rename from tests/cases/fourslash/refactorConvertToNamedParameters_arrowFunctionWithContextualType.ts rename to tests/cases/fourslash/refactorConvertParamsToDestructuredObject_arrowFunctionWithType.ts index 05a0f6f54fa..2539d97d04d 100644 --- a/tests/cases/fourslash/refactorConvertToNamedParameters_arrowFunctionWithContextualType.ts +++ b/tests/cases/fourslash/refactorConvertParamsToDestructuredObject_arrowFunctionWithType.ts @@ -4,4 +4,4 @@ ////foo(1, 2); goTo.select("a", "b"); -verify.not.refactorAvailable("Convert to named parameters"); +verify.not.refactorAvailable("Convert parameters to destructured object"); diff --git a/tests/cases/fourslash/refactorConvertToNamedParameters_callComments.ts b/tests/cases/fourslash/refactorConvertParamsToDestructuredObject_callComments.ts similarity index 69% rename from tests/cases/fourslash/refactorConvertToNamedParameters_callComments.ts rename to tests/cases/fourslash/refactorConvertParamsToDestructuredObject_callComments.ts index 6fb06fe938b..2e30f96cd59 100644 --- a/tests/cases/fourslash/refactorConvertToNamedParameters_callComments.ts +++ b/tests/cases/fourslash/refactorConvertParamsToDestructuredObject_callComments.ts @@ -7,9 +7,9 @@ goTo.select("a", "b"); edit.applyRefactor({ - refactorName: "Convert to named parameters", - actionName: "Convert to named parameters", - actionDescription: "Convert to named parameters", + refactorName: "Convert parameters to destructured object", + actionName: "Convert parameters to destructured object", + actionDescription: "Convert parameters to destructured object", newContent: `function foo({ a, b, rest = [] }: { a: number; b: number; rest?: number[]; }) { return a + b; } diff --git a/tests/cases/fourslash/refactorConvertToNamedParameters_callComments2.ts b/tests/cases/fourslash/refactorConvertParamsToDestructuredObject_callComments2.ts similarity index 74% rename from tests/cases/fourslash/refactorConvertToNamedParameters_callComments2.ts rename to tests/cases/fourslash/refactorConvertParamsToDestructuredObject_callComments2.ts index 96a56d7024d..fcb50b6b8e1 100644 --- a/tests/cases/fourslash/refactorConvertToNamedParameters_callComments2.ts +++ b/tests/cases/fourslash/refactorConvertParamsToDestructuredObject_callComments2.ts @@ -16,9 +16,9 @@ goTo.select("a", "b"); /* The expected content is currently wrong. The new argument object has the wrong formatting. */ edit.applyRefactor({ - refactorName: "Convert to named parameters", - actionName: "Convert to named parameters", - actionDescription: "Convert to named parameters", + refactorName: "Convert parameters to destructured object", + actionName: "Convert parameters to destructured object", + actionDescription: "Convert parameters to destructured object", newContent: `function foo({ a, b, rest = [] }: { a: number; b: number; rest?: number[]; }) { return a + b; } diff --git a/tests/cases/fourslash/refactorConvertToNamedParameters_chainedCall.ts b/tests/cases/fourslash/refactorConvertParamsToDestructuredObject_chainedCall.ts similarity index 62% rename from tests/cases/fourslash/refactorConvertToNamedParameters_chainedCall.ts rename to tests/cases/fourslash/refactorConvertParamsToDestructuredObject_chainedCall.ts index 0fb20ec864d..0b033200666 100644 --- a/tests/cases/fourslash/refactorConvertToNamedParameters_chainedCall.ts +++ b/tests/cases/fourslash/refactorConvertParamsToDestructuredObject_chainedCall.ts @@ -7,9 +7,9 @@ goTo.select("a", "b"); edit.applyRefactor({ - refactorName: "Convert to named parameters", - actionName: "Convert to named parameters", - actionDescription: "Convert to named parameters", + refactorName: "Convert parameters to destructured object", + actionName: "Convert parameters to destructured object", + actionDescription: "Convert parameters to destructured object", newContent: `function foo({ a, b }: { a: number; b: number; }) { return { bar: () => a + b }; } diff --git a/tests/cases/fourslash/refactorConvertToNamedParameters_classDeclarationAliasing.ts b/tests/cases/fourslash/refactorConvertParamsToDestructuredObject_classDeclarationAliasing.ts similarity index 65% rename from tests/cases/fourslash/refactorConvertToNamedParameters_classDeclarationAliasing.ts rename to tests/cases/fourslash/refactorConvertParamsToDestructuredObject_classDeclarationAliasing.ts index 0914dedd57d..9b77ecc2024 100644 --- a/tests/cases/fourslash/refactorConvertToNamedParameters_classDeclarationAliasing.ts +++ b/tests/cases/fourslash/refactorConvertParamsToDestructuredObject_classDeclarationAliasing.ts @@ -9,9 +9,9 @@ goTo.select("a", "b"); // Refactor should not make changes edit.applyRefactor({ - refactorName: "Convert to named parameters", - actionName: "Convert to named parameters", - actionDescription: "Convert to named parameters", + refactorName: "Convert parameters to destructured object", + actionName: "Convert parameters to destructured object", + actionDescription: "Convert parameters to destructured object", newContent: `class Foo { constructor(a: number, b: number) { } } diff --git a/tests/cases/fourslash/refactorConvertToNamedParameters_classDeclarationGoodUsages.ts b/tests/cases/fourslash/refactorConvertParamsToDestructuredObject_classDeclarationGoodUsages.ts similarity index 73% rename from tests/cases/fourslash/refactorConvertToNamedParameters_classDeclarationGoodUsages.ts rename to tests/cases/fourslash/refactorConvertParamsToDestructuredObject_classDeclarationGoodUsages.ts index 858bccd60c1..beba49c17e3 100644 --- a/tests/cases/fourslash/refactorConvertToNamedParameters_classDeclarationGoodUsages.ts +++ b/tests/cases/fourslash/refactorConvertParamsToDestructuredObject_classDeclarationGoodUsages.ts @@ -14,9 +14,9 @@ goTo.select("a", "b"); edit.applyRefactor({ - refactorName: "Convert to named parameters", - actionName: "Convert to named parameters", - actionDescription: "Convert to named parameters", + refactorName: "Convert parameters to destructured object", + actionName: "Convert parameters to destructured object", + actionDescription: "Convert parameters to destructured object", newContent: `class C { static a: number = 2; constructor({ a, b }: { a: number; b: number; }) { } diff --git a/tests/cases/fourslash/refactorConvertToNamedParameters_classExpression.ts b/tests/cases/fourslash/refactorConvertParamsToDestructuredObject_classExpression.ts similarity index 61% rename from tests/cases/fourslash/refactorConvertToNamedParameters_classExpression.ts rename to tests/cases/fourslash/refactorConvertParamsToDestructuredObject_classExpression.ts index ee4b6051756..f779170d643 100644 --- a/tests/cases/fourslash/refactorConvertToNamedParameters_classExpression.ts +++ b/tests/cases/fourslash/refactorConvertParamsToDestructuredObject_classExpression.ts @@ -7,9 +7,9 @@ goTo.select("a", "b"); edit.applyRefactor({ - refactorName: "Convert to named parameters", - actionName: "Convert to named parameters", - actionDescription: "Convert to named parameters", + refactorName: "Convert parameters to destructured object", + actionName: "Convert parameters to destructured object", + actionDescription: "Convert parameters to destructured object", newContent: `const c = class { constructor({ a, b = { x: 1 } }: { a: number; b?: { x: number; }; }) { } } diff --git a/tests/cases/fourslash/refactorConvertToNamedParameters_classExpressionGoodUsages.ts b/tests/cases/fourslash/refactorConvertParamsToDestructuredObject_classExpressionGoodUsages.ts similarity index 67% rename from tests/cases/fourslash/refactorConvertToNamedParameters_classExpressionGoodUsages.ts rename to tests/cases/fourslash/refactorConvertParamsToDestructuredObject_classExpressionGoodUsages.ts index f8023b9898c..ce0054fd92a 100644 --- a/tests/cases/fourslash/refactorConvertToNamedParameters_classExpressionGoodUsages.ts +++ b/tests/cases/fourslash/refactorConvertParamsToDestructuredObject_classExpressionGoodUsages.ts @@ -10,9 +10,9 @@ goTo.select("a", "b"); edit.applyRefactor({ - refactorName: "Convert to named parameters", - actionName: "Convert to named parameters", - actionDescription: "Convert to named parameters", + refactorName: "Convert parameters to destructured object", + actionName: "Convert parameters to destructured object", + actionDescription: "Convert parameters to destructured object", newContent: `const c = class C { static a: number = 2; constructor({ a, b }: { a: number; b: number; }) { } diff --git a/tests/cases/fourslash/refactorConvertToNamedParameters_classExpressionHeritage.ts b/tests/cases/fourslash/refactorConvertParamsToDestructuredObject_classExpressionHeritage.ts similarity index 68% rename from tests/cases/fourslash/refactorConvertToNamedParameters_classExpressionHeritage.ts rename to tests/cases/fourslash/refactorConvertParamsToDestructuredObject_classExpressionHeritage.ts index 14b9639c2ad..5318899ffa4 100644 --- a/tests/cases/fourslash/refactorConvertToNamedParameters_classExpressionHeritage.ts +++ b/tests/cases/fourslash/refactorConvertParamsToDestructuredObject_classExpressionHeritage.ts @@ -12,9 +12,9 @@ goTo.select("a", "b"); // Refactor should not make changes edit.applyRefactor({ - refactorName: "Convert to named parameters", - actionName: "Convert to named parameters", - actionDescription: "Convert to named parameters", + refactorName: "Convert parameters to destructured object", + actionName: "Convert parameters to destructured object", + actionDescription: "Convert parameters to destructured object", newContent: `const foo = class Foo { constructor(a: number, b: number) { } } diff --git a/tests/cases/fourslash/refactorConvertToNamedParameters_classTypeParameters.ts b/tests/cases/fourslash/refactorConvertParamsToDestructuredObject_classTypeParameters.ts similarity index 63% rename from tests/cases/fourslash/refactorConvertToNamedParameters_classTypeParameters.ts rename to tests/cases/fourslash/refactorConvertParamsToDestructuredObject_classTypeParameters.ts index 7d626215572..d8c884356bd 100644 --- a/tests/cases/fourslash/refactorConvertToNamedParameters_classTypeParameters.ts +++ b/tests/cases/fourslash/refactorConvertParamsToDestructuredObject_classTypeParameters.ts @@ -10,9 +10,9 @@ goTo.select("a", "b"); edit.applyRefactor({ - refactorName: "Convert to named parameters", - actionName: "Convert to named parameters", - actionDescription: "Convert to named parameters", + refactorName: "Convert parameters to destructured object", + actionName: "Convert parameters to destructured object", + actionDescription: "Convert parameters to destructured object", newContent: `class Foo { bar({ t, s }: { t: T; s: T; }) { return s; diff --git a/tests/cases/fourslash/refactorConvertToNamedParameters_constructor.ts b/tests/cases/fourslash/refactorConvertParamsToDestructuredObject_constructor.ts similarity index 69% rename from tests/cases/fourslash/refactorConvertToNamedParameters_constructor.ts rename to tests/cases/fourslash/refactorConvertParamsToDestructuredObject_constructor.ts index 86b1f9eb610..1503f2fe7eb 100644 --- a/tests/cases/fourslash/refactorConvertToNamedParameters_constructor.ts +++ b/tests/cases/fourslash/refactorConvertParamsToDestructuredObject_constructor.ts @@ -12,9 +12,9 @@ goTo.select("a", "b"); edit.applyRefactor({ - refactorName: "Convert to named parameters", - actionName: "Convert to named parameters", - actionDescription: "Convert to named parameters", + refactorName: "Convert parameters to destructured object", + actionName: "Convert parameters to destructured object", + actionDescription: "Convert parameters to destructured object", newContent: `class Foo { t: string; s: string; diff --git a/tests/cases/fourslash/refactorConvertToNamedParameters_defaultClass.ts b/tests/cases/fourslash/refactorConvertParamsToDestructuredObject_defaultClass.ts similarity index 65% rename from tests/cases/fourslash/refactorConvertToNamedParameters_defaultClass.ts rename to tests/cases/fourslash/refactorConvertParamsToDestructuredObject_defaultClass.ts index a056a82871b..17c7580fc88 100644 --- a/tests/cases/fourslash/refactorConvertToNamedParameters_defaultClass.ts +++ b/tests/cases/fourslash/refactorConvertParamsToDestructuredObject_defaultClass.ts @@ -5,4 +5,4 @@ ////} goTo.select("a", "b"); -verify.not.refactorAvailable("Convert to named parameters"); +verify.not.refactorAvailable("Convert parameters to destructured object"); diff --git a/tests/cases/fourslash/refactorConvertToNamedParameters_function.ts b/tests/cases/fourslash/refactorConvertParamsToDestructuredObject_function.ts similarity index 58% rename from tests/cases/fourslash/refactorConvertToNamedParameters_function.ts rename to tests/cases/fourslash/refactorConvertParamsToDestructuredObject_function.ts index 0834bf288fc..d5eed686068 100644 --- a/tests/cases/fourslash/refactorConvertToNamedParameters_function.ts +++ b/tests/cases/fourslash/refactorConvertParamsToDestructuredObject_function.ts @@ -7,9 +7,9 @@ goTo.select("a", "b"); edit.applyRefactor({ - refactorName: "Convert to named parameters", - actionName: "Convert to named parameters", - actionDescription: "Convert to named parameters", + refactorName: "Convert parameters to destructured object", + actionName: "Convert parameters to destructured object", + actionDescription: "Convert parameters to destructured object", newContent: `function f({ a, b }: { a: number; b: string; }): string { return b; } diff --git a/tests/cases/fourslash/refactorConvertToNamedParameters_functionComments.ts b/tests/cases/fourslash/refactorConvertParamsToDestructuredObject_functionComments.ts similarity index 76% rename from tests/cases/fourslash/refactorConvertToNamedParameters_functionComments.ts rename to tests/cases/fourslash/refactorConvertParamsToDestructuredObject_functionComments.ts index 20238ac81de..5340004a060 100644 --- a/tests/cases/fourslash/refactorConvertToNamedParameters_functionComments.ts +++ b/tests/cases/fourslash/refactorConvertParamsToDestructuredObject_functionComments.ts @@ -10,9 +10,9 @@ goTo.select("a", "b"); edit.applyRefactor({ - refactorName: "Convert to named parameters", - actionName: "Convert to named parameters", - actionDescription: "Convert to named parameters", + refactorName: "Convert parameters to destructured object", + actionName: "Convert parameters to destructured object", + actionDescription: "Convert parameters to destructured object", newContent: `foo({ a: 1, b: 2 }); /**a*/ /**b*/ function foo(/**this1*/ this /**this2*/: /**void1*/ void /**void2*/, { a, b = /**k*/ 1 /**l*/ }: { /**c*/ a /**d*/: /**e*/ number /**f*/; /**g*/ b /**h*/?: /**i*/ number /**j*/; }) { // m diff --git a/tests/cases/fourslash/refactorConvertToNamedParameters_functionComments1.ts b/tests/cases/fourslash/refactorConvertParamsToDestructuredObject_functionComments1.ts similarity index 58% rename from tests/cases/fourslash/refactorConvertToNamedParameters_functionComments1.ts rename to tests/cases/fourslash/refactorConvertParamsToDestructuredObject_functionComments1.ts index e0d34c8fe65..07bc755c076 100644 --- a/tests/cases/fourslash/refactorConvertToNamedParameters_functionComments1.ts +++ b/tests/cases/fourslash/refactorConvertParamsToDestructuredObject_functionComments1.ts @@ -6,9 +6,9 @@ goTo.select("a", "b"); edit.applyRefactor({ - refactorName: "Convert to named parameters", - actionName: "Convert to named parameters", - actionDescription: "Convert to named parameters", + refactorName: "Convert parameters to destructured object", + actionName: "Convert parameters to destructured object", + actionDescription: "Convert parameters to destructured object", newContent: `function foo({ a, b }: { a: number /** a */; b: number /** b */; }) { return a + b; }` diff --git a/tests/cases/fourslash/refactorConvertToNamedParameters_functionComments2.ts b/tests/cases/fourslash/refactorConvertParamsToDestructuredObject_functionComments2.ts similarity index 63% rename from tests/cases/fourslash/refactorConvertToNamedParameters_functionComments2.ts rename to tests/cases/fourslash/refactorConvertParamsToDestructuredObject_functionComments2.ts index 923b49b4198..c01ddf6735c 100644 --- a/tests/cases/fourslash/refactorConvertToNamedParameters_functionComments2.ts +++ b/tests/cases/fourslash/refactorConvertParamsToDestructuredObject_functionComments2.ts @@ -11,9 +11,9 @@ goTo.select("a", "b"); edit.applyRefactor({ - refactorName: "Convert to named parameters", - actionName: "Convert to named parameters", - actionDescription: "Convert to named parameters", + refactorName: "Convert parameters to destructured object", + actionName: "Convert parameters to destructured object", + actionDescription: "Convert parameters to destructured object", newContent: `function foo(// comment { a, b }: { // a comment diff --git a/tests/cases/fourslash/refactorConvertToNamedParameters_functionExpression.ts b/tests/cases/fourslash/refactorConvertParamsToDestructuredObject_functionExpression.ts similarity index 56% rename from tests/cases/fourslash/refactorConvertToNamedParameters_functionExpression.ts rename to tests/cases/fourslash/refactorConvertParamsToDestructuredObject_functionExpression.ts index e8aa6a92dd8..c4e81cf7926 100644 --- a/tests/cases/fourslash/refactorConvertToNamedParameters_functionExpression.ts +++ b/tests/cases/fourslash/refactorConvertParamsToDestructuredObject_functionExpression.ts @@ -5,9 +5,9 @@ goTo.select("a", "b"); edit.applyRefactor({ - refactorName: "Convert to named parameters", - actionName: "Convert to named parameters", - actionDescription: "Convert to named parameters", + refactorName: "Convert parameters to destructured object", + actionName: "Convert parameters to destructured object", + actionDescription: "Convert parameters to destructured object", newContent: `const foo = function({ a, b }: { a: number; b: number; }) { }; foo({ a: 1, b: 2 });` }); \ No newline at end of file diff --git a/tests/cases/fourslash/refactorConvertToNamedParameters_functionTypeParameters.ts b/tests/cases/fourslash/refactorConvertParamsToDestructuredObject_functionTypeParameters.ts similarity index 57% rename from tests/cases/fourslash/refactorConvertToNamedParameters_functionTypeParameters.ts rename to tests/cases/fourslash/refactorConvertParamsToDestructuredObject_functionTypeParameters.ts index a1597fdeed1..9a27ae4f09e 100644 --- a/tests/cases/fourslash/refactorConvertToNamedParameters_functionTypeParameters.ts +++ b/tests/cases/fourslash/refactorConvertParamsToDestructuredObject_functionTypeParameters.ts @@ -7,9 +7,9 @@ goTo.select("a", "b"); edit.applyRefactor({ - refactorName: "Convert to named parameters", - actionName: "Convert to named parameters", - actionDescription: "Convert to named parameters", + refactorName: "Convert parameters to destructured object", + actionName: "Convert parameters to destructured object", + actionDescription: "Convert parameters to destructured object", newContent: `function foo({ t, s }: { t: T; s: S; }) { return s; } diff --git a/tests/cases/fourslash/refactorConvertToNamedParameters_inheritedConstructor.ts b/tests/cases/fourslash/refactorConvertParamsToDestructuredObject_inheritedConstructor.ts similarity index 73% rename from tests/cases/fourslash/refactorConvertToNamedParameters_inheritedConstructor.ts rename to tests/cases/fourslash/refactorConvertParamsToDestructuredObject_inheritedConstructor.ts index bde7839a60e..6e27c33078a 100644 --- a/tests/cases/fourslash/refactorConvertToNamedParameters_inheritedConstructor.ts +++ b/tests/cases/fourslash/refactorConvertParamsToDestructuredObject_inheritedConstructor.ts @@ -12,9 +12,9 @@ goTo.select("a", "b"); `new Bar("a", "b")` should be modified by the refactor to be `new Bar({ t: "a", s: "b" })` */ edit.applyRefactor({ - refactorName: "Convert to named parameters", - actionName: "Convert to named parameters", - actionDescription: "Convert to named parameters", + refactorName: "Convert parameters to destructured object", + actionName: "Convert parameters to destructured object", + actionDescription: "Convert parameters to destructured object", newContent: `class Foo { constructor({ t, s }: { t: string; s: string; }) { } } diff --git a/tests/cases/fourslash/refactorConvertToNamedParameters_inheritedMethod.ts b/tests/cases/fourslash/refactorConvertParamsToDestructuredObject_inheritedMethod.ts similarity index 68% rename from tests/cases/fourslash/refactorConvertToNamedParameters_inheritedMethod.ts rename to tests/cases/fourslash/refactorConvertParamsToDestructuredObject_inheritedMethod.ts index 3214ea4bf53..a04560886c0 100644 --- a/tests/cases/fourslash/refactorConvertToNamedParameters_inheritedMethod.ts +++ b/tests/cases/fourslash/refactorConvertParamsToDestructuredObject_inheritedMethod.ts @@ -11,9 +11,9 @@ goTo.select("a", "b"); edit.applyRefactor({ - refactorName: "Convert to named parameters", - actionName: "Convert to named parameters", - actionDescription: "Convert to named parameters", + refactorName: "Convert parameters to destructured object", + actionName: "Convert parameters to destructured object", + actionDescription: "Convert parameters to destructured object", newContent: `class Foo { bar({ t, s }: { t: string; s: string; }): string { return s + t; diff --git a/tests/cases/fourslash/refactorConvertToNamedParameters_initializer.ts b/tests/cases/fourslash/refactorConvertParamsToDestructuredObject_initializer.ts similarity index 59% rename from tests/cases/fourslash/refactorConvertToNamedParameters_initializer.ts rename to tests/cases/fourslash/refactorConvertParamsToDestructuredObject_initializer.ts index 1e63f44fc35..3f0da9f13a3 100644 --- a/tests/cases/fourslash/refactorConvertToNamedParameters_initializer.ts +++ b/tests/cases/fourslash/refactorConvertParamsToDestructuredObject_initializer.ts @@ -7,9 +7,9 @@ goTo.select("a", "b"); edit.applyRefactor({ - refactorName: "Convert to named parameters", - actionName: "Convert to named parameters", - actionDescription: "Convert to named parameters", + refactorName: "Convert parameters to destructured object", + actionName: "Convert parameters to destructured object", + actionDescription: "Convert parameters to destructured object", newContent: `function f({ a, b = "1" }: { a: number; b?: string; }): string { return b; } diff --git a/tests/cases/fourslash/refactorConvertToNamedParameters_initializerInference.ts b/tests/cases/fourslash/refactorConvertParamsToDestructuredObject_initializerInference.ts similarity index 62% rename from tests/cases/fourslash/refactorConvertToNamedParameters_initializerInference.ts rename to tests/cases/fourslash/refactorConvertParamsToDestructuredObject_initializerInference.ts index b6bdb7a88c2..f2b92fc89e7 100644 --- a/tests/cases/fourslash/refactorConvertToNamedParameters_initializerInference.ts +++ b/tests/cases/fourslash/refactorConvertParamsToDestructuredObject_initializerInference.ts @@ -7,9 +7,9 @@ goTo.select("a", "b"); edit.applyRefactor({ - refactorName: "Convert to named parameters", - actionName: "Convert to named parameters", - actionDescription: "Convert to named parameters", + refactorName: "Convert parameters to destructured object", + actionName: "Convert parameters to destructured object", + actionDescription: "Convert parameters to destructured object", newContent: `function f({ a, b = { x: 1, z: { s: true } } }: { a: number; b?: { x: number; z: { s: boolean; }; }; }) { return b; } diff --git a/tests/cases/fourslash/refactorConvertToNamedParameters_method.ts b/tests/cases/fourslash/refactorConvertParamsToDestructuredObject_method.ts similarity index 65% rename from tests/cases/fourslash/refactorConvertToNamedParameters_method.ts rename to tests/cases/fourslash/refactorConvertParamsToDestructuredObject_method.ts index d7dce948cae..f3f78de391e 100644 --- a/tests/cases/fourslash/refactorConvertToNamedParameters_method.ts +++ b/tests/cases/fourslash/refactorConvertParamsToDestructuredObject_method.ts @@ -10,9 +10,9 @@ goTo.select("a", "b"); edit.applyRefactor({ - refactorName: "Convert to named parameters", - actionName: "Convert to named parameters", - actionDescription: "Convert to named parameters", + refactorName: "Convert parameters to destructured object", + actionName: "Convert parameters to destructured object", + actionDescription: "Convert parameters to destructured object", newContent: `class Foo { bar({ t, s }: { t: string; s: string; }): string { return s + t; diff --git a/tests/cases/fourslash/refactorConvertToNamedParameters_methodCallUnion.ts b/tests/cases/fourslash/refactorConvertParamsToDestructuredObject_methodCallUnion.ts similarity index 70% rename from tests/cases/fourslash/refactorConvertToNamedParameters_methodCallUnion.ts rename to tests/cases/fourslash/refactorConvertParamsToDestructuredObject_methodCallUnion.ts index e4cafbeff3e..031b50dc45e 100644 --- a/tests/cases/fourslash/refactorConvertToNamedParameters_methodCallUnion.ts +++ b/tests/cases/fourslash/refactorConvertParamsToDestructuredObject_methodCallUnion.ts @@ -14,9 +14,9 @@ goTo.select("a", "b"); // Refactor should not make changes edit.applyRefactor({ - refactorName: "Convert to named parameters", - actionName: "Convert to named parameters", - actionDescription: "Convert to named parameters", + refactorName: "Convert parameters to destructured object", + actionName: "Convert parameters to destructured object", + actionDescription: "Convert parameters to destructured object", newContent: `class A { foo(a: number, b: number) { return a + b; } } diff --git a/tests/cases/fourslash/refactorConvertToNamedParameters_methodCalls.ts b/tests/cases/fourslash/refactorConvertParamsToDestructuredObject_methodCalls.ts similarity index 68% rename from tests/cases/fourslash/refactorConvertToNamedParameters_methodCalls.ts rename to tests/cases/fourslash/refactorConvertParamsToDestructuredObject_methodCalls.ts index f84e0d7b023..d1347ad877b 100644 --- a/tests/cases/fourslash/refactorConvertToNamedParameters_methodCalls.ts +++ b/tests/cases/fourslash/refactorConvertParamsToDestructuredObject_methodCalls.ts @@ -11,9 +11,9 @@ goTo.select("a", "b"); edit.applyRefactor({ - refactorName: "Convert to named parameters", - actionName: "Convert to named parameters", - actionDescription: "Convert to named parameters", + refactorName: "Convert parameters to destructured object", + actionName: "Convert parameters to destructured object", + actionDescription: "Convert parameters to destructured object", newContent: `class Foo { bar({ t, s }: { t: string; s: string; }): string { return s + t; diff --git a/tests/cases/fourslash/refactorConvertToNamedParameters_methodOverrides.ts b/tests/cases/fourslash/refactorConvertParamsToDestructuredObject_methodOverrides.ts similarity index 62% rename from tests/cases/fourslash/refactorConvertToNamedParameters_methodOverrides.ts rename to tests/cases/fourslash/refactorConvertParamsToDestructuredObject_methodOverrides.ts index b6daac17dd4..1941c85b28e 100644 --- a/tests/cases/fourslash/refactorConvertToNamedParameters_methodOverrides.ts +++ b/tests/cases/fourslash/refactorConvertParamsToDestructuredObject_methodOverrides.ts @@ -13,9 +13,9 @@ goTo.select("a", "b"); edit.applyRefactor({ - refactorName: "Convert to named parameters", - actionName: "Convert to named parameters", - actionDescription: "Convert to named parameters", + refactorName: "Convert parameters to destructured object", + actionName: "Convert parameters to destructured object", + actionDescription: "Convert parameters to destructured object", newContent: `class A { foo(a: number, b: number) { } } @@ -29,9 +29,9 @@ b.foo(5, 6);` }); goTo.select("c", "d"); edit.applyRefactor({ - refactorName: "Convert to named parameters", - actionName: "Convert to named parameters", - actionDescription: "Convert to named parameters", + refactorName: "Convert parameters to destructured object", + actionName: "Convert parameters to destructured object", + actionDescription: "Convert parameters to destructured object", newContent: `class A { foo(a: number, b: number) { } } diff --git a/tests/cases/fourslash/refactorConvertToNamedParameters_overloads.ts b/tests/cases/fourslash/refactorConvertParamsToDestructuredObject_overloads.ts similarity index 68% rename from tests/cases/fourslash/refactorConvertToNamedParameters_overloads.ts rename to tests/cases/fourslash/refactorConvertParamsToDestructuredObject_overloads.ts index 772f8ea8848..3655ecc0c58 100644 --- a/tests/cases/fourslash/refactorConvertToNamedParameters_overloads.ts +++ b/tests/cases/fourslash/refactorConvertParamsToDestructuredObject_overloads.ts @@ -7,4 +7,4 @@ ////f(2); goTo.select("a", "b"); -verify.not.refactorAvailable("Convert to named parameters"); \ No newline at end of file +verify.not.refactorAvailable("Convert parameters to destructured object"); \ No newline at end of file diff --git a/tests/cases/fourslash/refactorConvertToNamedParameters_paramDecorator.ts b/tests/cases/fourslash/refactorConvertParamsToDestructuredObject_paramDecorator.ts similarity index 75% rename from tests/cases/fourslash/refactorConvertToNamedParameters_paramDecorator.ts rename to tests/cases/fourslash/refactorConvertParamsToDestructuredObject_paramDecorator.ts index 180798af95d..c8d7333c9f7 100644 --- a/tests/cases/fourslash/refactorConvertToNamedParameters_paramDecorator.ts +++ b/tests/cases/fourslash/refactorConvertParamsToDestructuredObject_paramDecorator.ts @@ -8,4 +8,4 @@ ////} goTo.select("a", "b"); -verify.not.refactorAvailable("Convert to named parameters"); \ No newline at end of file +verify.not.refactorAvailable("Convert parameters to destructured object"); \ No newline at end of file diff --git a/tests/cases/fourslash/refactorConvertToNamedParameters_recursiveFunction.ts b/tests/cases/fourslash/refactorConvertParamsToDestructuredObject_recursiveFunction.ts similarity index 64% rename from tests/cases/fourslash/refactorConvertToNamedParameters_recursiveFunction.ts rename to tests/cases/fourslash/refactorConvertParamsToDestructuredObject_recursiveFunction.ts index d1513cb7bf0..7655af05100 100644 --- a/tests/cases/fourslash/refactorConvertToNamedParameters_recursiveFunction.ts +++ b/tests/cases/fourslash/refactorConvertParamsToDestructuredObject_recursiveFunction.ts @@ -9,9 +9,9 @@ goTo.select("a", "b"); edit.applyRefactor({ - refactorName: "Convert to named parameters", - actionName: "Convert to named parameters", - actionDescription: "Convert to named parameters", + refactorName: "Convert parameters to destructured object", + actionName: "Convert parameters to destructured object", + actionDescription: "Convert parameters to destructured object", newContent: `const f = function foo({ a, b }: { a: number; b: number; }) { foo({ a: 1, b: 2 }); } diff --git a/tests/cases/fourslash/refactorConvertToNamedParameters_restParamInference.ts b/tests/cases/fourslash/refactorConvertParamsToDestructuredObject_restParamInference.ts similarity index 64% rename from tests/cases/fourslash/refactorConvertToNamedParameters_restParamInference.ts rename to tests/cases/fourslash/refactorConvertParamsToDestructuredObject_restParamInference.ts index 36ed5084fe2..1c6350d89f5 100644 --- a/tests/cases/fourslash/refactorConvertToNamedParameters_restParamInference.ts +++ b/tests/cases/fourslash/refactorConvertParamsToDestructuredObject_restParamInference.ts @@ -6,9 +6,9 @@ goTo.select("a", "b"); edit.applyRefactor({ - refactorName: "Convert to named parameters", - actionName: "Convert to named parameters", - actionDescription: "Convert to named parameters", + refactorName: "Convert parameters to destructured object", + actionName: "Convert parameters to destructured object", + actionDescription: "Convert parameters to destructured object", newContent: `function log({ a, b, args = [] }: { a: number; b: number; args?: any[]; }) { } let l = log({ a: -1, b: -2, args: [3, 4, 5] }); let k = log({ a: 1, b: 2 });` diff --git a/tests/cases/fourslash/refactorConvertToNamedParameters_staticMethod.ts b/tests/cases/fourslash/refactorConvertParamsToDestructuredObject_staticMethod.ts similarity index 64% rename from tests/cases/fourslash/refactorConvertToNamedParameters_staticMethod.ts rename to tests/cases/fourslash/refactorConvertParamsToDestructuredObject_staticMethod.ts index c84c1aa20d4..8c19582c145 100644 --- a/tests/cases/fourslash/refactorConvertToNamedParameters_staticMethod.ts +++ b/tests/cases/fourslash/refactorConvertParamsToDestructuredObject_staticMethod.ts @@ -9,9 +9,9 @@ goTo.select("a", "b"); edit.applyRefactor({ - refactorName: "Convert to named parameters", - actionName: "Convert to named parameters", - actionDescription: "Convert to named parameters", + refactorName: "Convert parameters to destructured object", + actionName: "Convert parameters to destructured object", + actionDescription: "Convert parameters to destructured object", newContent: `class Foo { static bar({ t, s }: { t: string; s: string; }): string { return s + t; diff --git a/tests/cases/fourslash/refactorConvertToNamedParameters_superCall.ts b/tests/cases/fourslash/refactorConvertParamsToDestructuredObject_superCall.ts similarity index 69% rename from tests/cases/fourslash/refactorConvertToNamedParameters_superCall.ts rename to tests/cases/fourslash/refactorConvertParamsToDestructuredObject_superCall.ts index c5d15903ef5..56227a9078a 100644 --- a/tests/cases/fourslash/refactorConvertToNamedParameters_superCall.ts +++ b/tests/cases/fourslash/refactorConvertParamsToDestructuredObject_superCall.ts @@ -11,9 +11,9 @@ goTo.select("a", "b"); edit.applyRefactor({ - refactorName: "Convert to named parameters", - actionName: "Convert to named parameters", - actionDescription: "Convert to named parameters", + refactorName: "Convert parameters to destructured object", + actionName: "Convert parameters to destructured object", + actionDescription: "Convert parameters to destructured object", newContent: `class A { constructor({ a, b }: { a: string; b: string; }) { } } diff --git a/tests/cases/fourslash/refactorConvertToNamedParameters_thisParam.ts b/tests/cases/fourslash/refactorConvertParamsToDestructuredObject_thisParam.ts similarity index 60% rename from tests/cases/fourslash/refactorConvertToNamedParameters_thisParam.ts rename to tests/cases/fourslash/refactorConvertParamsToDestructuredObject_thisParam.ts index e4a96bc7bf1..05a6620707f 100644 --- a/tests/cases/fourslash/refactorConvertToNamedParameters_thisParam.ts +++ b/tests/cases/fourslash/refactorConvertParamsToDestructuredObject_thisParam.ts @@ -7,9 +7,9 @@ goTo.select("a", "b"); edit.applyRefactor({ - refactorName: "Convert to named parameters", - actionName: "Convert to named parameters", - actionDescription: "Convert to named parameters", + refactorName: "Convert parameters to destructured object", + actionName: "Convert parameters to destructured object", + actionDescription: "Convert parameters to destructured object", newContent: `function foo(this: void, { t, s }: { t: string; s: string; }) { return s; } diff --git a/tests/cases/fourslash/refactorConvertToNamedParameters_typedRestParam.ts b/tests/cases/fourslash/refactorConvertParamsToDestructuredObject_typedRestParam.ts similarity index 75% rename from tests/cases/fourslash/refactorConvertToNamedParameters_typedRestParam.ts rename to tests/cases/fourslash/refactorConvertParamsToDestructuredObject_typedRestParam.ts index 34e0331f466..88401d83c4b 100644 --- a/tests/cases/fourslash/refactorConvertToNamedParameters_typedRestParam.ts +++ b/tests/cases/fourslash/refactorConvertParamsToDestructuredObject_typedRestParam.ts @@ -6,9 +6,9 @@ goTo.select("a", "b"); edit.applyRefactor({ - refactorName: "Convert to named parameters", - actionName: "Convert to named parameters", - actionDescription: "Convert to named parameters", + refactorName: "Convert parameters to destructured object", + actionName: "Convert parameters to destructured object", + actionDescription: "Convert parameters to destructured object", newContent: `function buildName({ firstName, middleName, restOfName = [] }: { firstName: string; middleName?: string; restOfName?: string[]; }) { } let employeeName = buildName({ firstName: "Joseph", middleName: "Samuel", restOfName: ["Lucas", "MacKinzie"] }); let myName = buildName({ firstName: "Joseph" });` diff --git a/tests/cases/fourslash/refactorConvertToNamedParameters_varArrowFunction.ts b/tests/cases/fourslash/refactorConvertParamsToDestructuredObject_varArrowFunction.ts similarity index 61% rename from tests/cases/fourslash/refactorConvertToNamedParameters_varArrowFunction.ts rename to tests/cases/fourslash/refactorConvertParamsToDestructuredObject_varArrowFunction.ts index ec25b50b067..abe870574f0 100644 --- a/tests/cases/fourslash/refactorConvertToNamedParameters_varArrowFunction.ts +++ b/tests/cases/fourslash/refactorConvertParamsToDestructuredObject_varArrowFunction.ts @@ -4,4 +4,4 @@ ////foo(1, 2); goTo.select("a", "b"); -verify.not.refactorAvailable("Convert to named parameters"); +verify.not.refactorAvailable("Convert parameters to destructured object"); From 34ea77f67431452623bbc9ef0e67269e8190c22a Mon Sep 17 00:00:00 2001 From: Sheetal Nandi Date: Thu, 14 Mar 2019 14:02:53 -0700 Subject: [PATCH 7/7] Pass time to the vfs of resolveJsonModule --- src/testRunner/unittests/tsbuild/resolveJsonModule.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/testRunner/unittests/tsbuild/resolveJsonModule.ts b/src/testRunner/unittests/tsbuild/resolveJsonModule.ts index 514defb3583..1fe124f56b4 100644 --- a/src/testRunner/unittests/tsbuild/resolveJsonModule.ts +++ b/src/testRunner/unittests/tsbuild/resolveJsonModule.ts @@ -1,9 +1,10 @@ namespace ts { describe("unittests:: tsbuild:: with resolveJsonModule option", () => { let projFs: vfs.FileSystem; + const { time, tick } = getTime(); const allExpectedOutputs = ["/src/dist/src/index.js", "/src/dist/src/index.d.ts", "/src/dist/src/hello.json"]; before(() => { - projFs = loadProjectFromDisk("tests/projects/resolveJsonModuleAndComposite"); + projFs = loadProjectFromDisk("tests/projects/resolveJsonModuleAndComposite", time); }); after(() => { @@ -69,7 +70,7 @@ export default hello.hello`); for (const output of [...allExpectedOutputs, "/src/dist/src/index.js.map"]) { assert(fs.existsSync(output), `Expect file ${output} to exist`); } - + tick(); const newBuilder = createSolutionBuilder(host, [configFile], { verbose: true }); newBuilder.buildAllProjects(); host.assertDiagnosticMessages(