From fdb49fecd58f418289935d210edc8630b3012dce Mon Sep 17 00:00:00 2001 From: Oleksandr T Date: Sun, 28 May 2023 12:44:18 +0300 Subject: [PATCH] fix(54366): skip type truncation --- src/services/codefixes/helpers.ts | 2 +- .../codeFixAddMissingFunctionDeclaration28.ts | 57 ++++++++++++++ .../fourslash/codeFixAddMissingMember30.ts | 75 +++++++++++++++++++ 3 files changed, 133 insertions(+), 1 deletion(-) create mode 100644 tests/cases/fourslash/codeFixAddMissingFunctionDeclaration28.ts create mode 100644 tests/cases/fourslash/codeFixAddMissingMember30.ts diff --git a/src/services/codefixes/helpers.ts b/src/services/codefixes/helpers.ts index 39215e7185f44..18db6cf68a9a3 100644 --- a/src/services/codefixes/helpers.ts +++ b/src/services/codefixes/helpers.ts @@ -481,7 +481,7 @@ export function createSignatureDeclarationFromCallExpression( isIdentifier(arg) ? arg.text : isPropertyAccessExpression(arg) && isIdentifier(arg.name) ? arg.name.text : undefined); const instanceTypes = isJs ? [] : map(args, arg => checker.getTypeAtLocation(arg)); const { argumentTypeNodes, argumentTypeParameters } = getArgumentTypesAndTypeParameters( - checker, importAdder, instanceTypes, contextNode, scriptTarget, /*flags*/ undefined, tracker + checker, importAdder, instanceTypes, contextNode, scriptTarget, NodeBuilderFlags.NoTruncation, tracker ); const modifiers = modifierFlags diff --git a/tests/cases/fourslash/codeFixAddMissingFunctionDeclaration28.ts b/tests/cases/fourslash/codeFixAddMissingFunctionDeclaration28.ts new file mode 100644 index 0000000000000..ee23991684a42 --- /dev/null +++ b/tests/cases/fourslash/codeFixAddMissingFunctionDeclaration28.ts @@ -0,0 +1,57 @@ +/// + +////foo({ +//// prop001: '', +//// prop002: '', +//// prop003: '', +//// prop004: '', +//// prop005: '', +//// prop006: '', +//// prop007: '', +//// prop008: '', +//// prop009: '', +//// prop010: '', +//// prop011: '', +//// prop012: '', +//// prop013: '', +//// prop014: '', +//// prop015: '', +//// prop016: '', +//// prop017: '', +//// prop018: '', +//// prop019: '', +//// prop020: '', +////}); + +verify.codeFix({ + description: [ts.Diagnostics.Add_missing_function_declaration_0.message, "foo"], + index: 0, + newFileContent: +`foo({ + prop001: '', + prop002: '', + prop003: '', + prop004: '', + prop005: '', + prop006: '', + prop007: '', + prop008: '', + prop009: '', + prop010: '', + prop011: '', + prop012: '', + prop013: '', + prop014: '', + prop015: '', + prop016: '', + prop017: '', + prop018: '', + prop019: '', + prop020: '', +}); + +function foo(arg0: { prop001: string; prop002: string; prop003: string; prop004: string; prop005: string; prop006: string; prop007: string; prop008: string; prop009: string; prop010: string; prop011: string; prop012: string; prop013: string; prop014: string; prop015: string; prop016: string; prop017: string; prop018: string; prop019: string; prop020: string; }) { + throw new Error("Function not implemented."); +} +`, +}); diff --git a/tests/cases/fourslash/codeFixAddMissingMember30.ts b/tests/cases/fourslash/codeFixAddMissingMember30.ts new file mode 100644 index 0000000000000..ff0e8aafbe3cb --- /dev/null +++ b/tests/cases/fourslash/codeFixAddMissingMember30.ts @@ -0,0 +1,75 @@ +/// + +////class C { +//// constructor() { +//// this.foo({ +//// 'foo.a': '', +//// 'foo.b': '', +//// 'foo.c': '', +//// 'foo.d': '', +//// 'foo.e': '', +//// 'foo.f': '', +//// 'foo.g': '', +//// 'foo.h': '', +//// 'foo.i': '', +//// 'foo.j': '', +//// 'foo.k': '', +//// 'foo.l': '', +//// 'foo.m': '', +//// 'foo.n': '', +//// 'foo.o': '', +//// 'foo.p': '', +//// 'foo.q': '', +//// 'foo.r': '', +//// 'foo.s': '', +//// 'foo.t': '', +//// 'foo.u': '', +//// 'foo.v': '', +//// 'foo.w': '', +//// 'foo.x': '', +//// 'foo.y': '', +//// 'foo.z': '', +//// }); +//// } +////} + +verify.codeFix({ + description: [ts.Diagnostics.Declare_method_0.message, "foo"], + index: 0, + newFileContent: +`class C { + constructor() { + this.foo({ + 'foo.a': '', + 'foo.b': '', + 'foo.c': '', + 'foo.d': '', + 'foo.e': '', + 'foo.f': '', + 'foo.g': '', + 'foo.h': '', + 'foo.i': '', + 'foo.j': '', + 'foo.k': '', + 'foo.l': '', + 'foo.m': '', + 'foo.n': '', + 'foo.o': '', + 'foo.p': '', + 'foo.q': '', + 'foo.r': '', + 'foo.s': '', + 'foo.t': '', + 'foo.u': '', + 'foo.v': '', + 'foo.w': '', + 'foo.x': '', + 'foo.y': '', + 'foo.z': '', + }); + } + foo(arg0: { 'foo.a': string; 'foo.b': string; 'foo.c': string; 'foo.d': string; 'foo.e': string; 'foo.f': string; 'foo.g': string; 'foo.h': string; 'foo.i': string; 'foo.j': string; 'foo.k': string; 'foo.l': string; 'foo.m': string; 'foo.n': string; 'foo.o': string; 'foo.p': string; 'foo.q': string; 'foo.r': string; 'foo.s': string; 'foo.t': string; 'foo.u': string; 'foo.v': string; 'foo.w': string; 'foo.x': string; 'foo.y': string; 'foo.z': string; }) { + throw new Error("Method not implemented."); + } +}`, +});