Skip to content

Commit 8513f78

Browse files
authored
Fix getCodeFixesAtPosition for ts(2339) thows error False expression: Token end is child end (microsoft#43645)
* Fix getCodeFixesAtPosition for ts(2339) thows error False expression: Token end is child end Fixes microsoft#43191 * Add test
1 parent a910c8d commit 8513f78

File tree

2 files changed

+66
-2
lines changed

2 files changed

+66
-2
lines changed

src/services/codefixes/fixAddMissingMember.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -276,11 +276,11 @@ namespace ts.codefix {
276276
const binaryExpression = token.parent.parent as BinaryExpression;
277277
const otherExpression = token.parent === binaryExpression.left ? binaryExpression.right : binaryExpression.left;
278278
const widenedType = checker.getWidenedType(checker.getBaseTypeOfLiteralType(checker.getTypeAtLocation(otherExpression)));
279-
typeNode = checker.typeToTypeNode(widenedType, classDeclaration, /*flags*/ undefined);
279+
typeNode = checker.typeToTypeNode(widenedType, classDeclaration, NodeBuilderFlags.NoTruncation);
280280
}
281281
else {
282282
const contextualType = checker.getContextualType(token.parent as Expression);
283-
typeNode = contextualType ? checker.typeToTypeNode(contextualType, /*enclosingDeclaration*/ undefined, /*flags*/ undefined) : undefined;
283+
typeNode = contextualType ? checker.typeToTypeNode(contextualType, /*enclosingDeclaration*/ undefined, NodeBuilderFlags.NoTruncation) : undefined;
284284
}
285285
return typeNode || factory.createKeywordTypeNode(SyntaxKind.AnyKeyword);
286286
}
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
/// <reference path='fourslash.ts' />
2+
3+
////class C {
4+
//// method() {
5+
//// const {
6+
//// many01,
7+
//// many02,
8+
//// many03,
9+
//// many04,
10+
//// many05,
11+
//// many06,
12+
//// many07,
13+
//// many08,
14+
//// many09,
15+
//// many10,
16+
//// many11,
17+
//// many12,
18+
//// many13,
19+
//// many14,
20+
//// many15,
21+
//// many16,
22+
//// many17,
23+
//// many18,
24+
//// many19,
25+
//// many20,
26+
//// many21,
27+
//// many22
28+
//// } = this.foo;
29+
//// }
30+
////}
31+
32+
verify.codeFix({
33+
description: "Declare property 'foo'",
34+
index: 0,
35+
newFileContent: `class C {
36+
foo: { many01: any; many02: any; many03: any; many04: any; many05: any; many06: any; many07: any; many08: any; many09: any; many10: any; many11: any; many12: any; many13: any; many14: any; many15: any; many16: any; many17: any; many18: any; many19: any; many20: any; many21: any; many22: any; };
37+
method() {
38+
const {
39+
many01,
40+
many02,
41+
many03,
42+
many04,
43+
many05,
44+
many06,
45+
many07,
46+
many08,
47+
many09,
48+
many10,
49+
many11,
50+
many12,
51+
many13,
52+
many14,
53+
many15,
54+
many16,
55+
many17,
56+
many18,
57+
many19,
58+
many20,
59+
many21,
60+
many22
61+
} = this.foo;
62+
}
63+
}`
64+
});

0 commit comments

Comments
 (0)