Skip to content

Commit 733d7ae

Browse files
authored
fix(52749): Assertion failure in derived class completion (#52787)
1 parent 2c67c8f commit 733d7ae

File tree

3 files changed

+345
-1
lines changed

3 files changed

+345
-1
lines changed

src/services/codefixes/helpers.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -751,7 +751,7 @@ function createMethodImplementingSignatures(
751751
function getReturnTypeFromSignatures(signatures: readonly Signature[], checker: TypeChecker, context: TypeConstructionContext, enclosingDeclaration: ClassLikeDeclaration): TypeNode | undefined {
752752
if (length(signatures)) {
753753
const type = checker.getUnionType(map(signatures, checker.getReturnTypeOfSignature));
754-
return checker.typeToTypeNode(type, enclosingDeclaration, /*flags*/ undefined, getNoopSymbolTrackerWithResolver(context));
754+
return checker.typeToTypeNode(type, enclosingDeclaration, NodeBuilderFlags.NoTruncation, getNoopSymbolTrackerWithResolver(context));
755755
}
756756
}
757757

Lines changed: 319 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,319 @@
1+
=== /foo.ts ===
2+
// export class Observable<T> {
3+
// pipe(): Observable<T>;
4+
// pipe<A>(): Observable<A>;
5+
// pipe<A, B>(): Observable<B>;
6+
// pipe<A, B, C>(): Observable<C>;
7+
// pipe<A, B, C, D>(): Observable<D>;
8+
// pipe<A, B, C, D, E>(): Observable<E>;
9+
// pipe<A, B, C, D, E, F>(): Observable<F>;
10+
// pipe<A, B, C, D, E, F, G>(): Observable<G>;
11+
// pipe<A, B, C, D, E, F, G, H>(): Observable<H>;
12+
// pipe<A, B, C, D, E, F, G, H, I>(): Observable<I>;
13+
// pipe<A, B, C, D, E, F, G, H, I>(): Observable<unknown>;
14+
// }
15+
// export class Foo extends Observable<any> {
16+
//
17+
// ^
18+
// | ----------------------------------------------------------------------
19+
// | abstract
20+
// | accessor
21+
// | async
22+
// | constructor
23+
// | declare
24+
// | get
25+
// | override
26+
// | private
27+
// | protected
28+
// | public
29+
// | readonly
30+
// | set
31+
// | static
32+
// | (method) Observable<any>.pipe(): Observable<any> (+10 overloads)
33+
// | ----------------------------------------------------------------------
34+
// }
35+
36+
[
37+
{
38+
"marker": {
39+
"fileName": "/foo.ts",
40+
"position": 543,
41+
"name": ""
42+
},
43+
"item": {
44+
"flags": 0,
45+
"isGlobalCompletion": false,
46+
"isMemberCompletion": true,
47+
"isNewIdentifierLocation": true,
48+
"entries": [
49+
{
50+
"name": "abstract",
51+
"kind": "keyword",
52+
"kindModifiers": "",
53+
"sortText": "15",
54+
"displayParts": [
55+
{
56+
"text": "abstract",
57+
"kind": "keyword"
58+
}
59+
]
60+
},
61+
{
62+
"name": "accessor",
63+
"kind": "keyword",
64+
"kindModifiers": "",
65+
"sortText": "15",
66+
"displayParts": [
67+
{
68+
"text": "accessor",
69+
"kind": "keyword"
70+
}
71+
]
72+
},
73+
{
74+
"name": "async",
75+
"kind": "keyword",
76+
"kindModifiers": "",
77+
"sortText": "15",
78+
"displayParts": [
79+
{
80+
"text": "async",
81+
"kind": "keyword"
82+
}
83+
]
84+
},
85+
{
86+
"name": "constructor",
87+
"kind": "keyword",
88+
"kindModifiers": "",
89+
"sortText": "15",
90+
"displayParts": [
91+
{
92+
"text": "constructor",
93+
"kind": "keyword"
94+
}
95+
]
96+
},
97+
{
98+
"name": "declare",
99+
"kind": "keyword",
100+
"kindModifiers": "",
101+
"sortText": "15",
102+
"displayParts": [
103+
{
104+
"text": "declare",
105+
"kind": "keyword"
106+
}
107+
]
108+
},
109+
{
110+
"name": "get",
111+
"kind": "keyword",
112+
"kindModifiers": "",
113+
"sortText": "15",
114+
"displayParts": [
115+
{
116+
"text": "get",
117+
"kind": "keyword"
118+
}
119+
]
120+
},
121+
{
122+
"name": "override",
123+
"kind": "keyword",
124+
"kindModifiers": "",
125+
"sortText": "15",
126+
"displayParts": [
127+
{
128+
"text": "override",
129+
"kind": "keyword"
130+
}
131+
]
132+
},
133+
{
134+
"name": "private",
135+
"kind": "keyword",
136+
"kindModifiers": "",
137+
"sortText": "15",
138+
"displayParts": [
139+
{
140+
"text": "private",
141+
"kind": "keyword"
142+
}
143+
]
144+
},
145+
{
146+
"name": "protected",
147+
"kind": "keyword",
148+
"kindModifiers": "",
149+
"sortText": "15",
150+
"displayParts": [
151+
{
152+
"text": "protected",
153+
"kind": "keyword"
154+
}
155+
]
156+
},
157+
{
158+
"name": "public",
159+
"kind": "keyword",
160+
"kindModifiers": "",
161+
"sortText": "15",
162+
"displayParts": [
163+
{
164+
"text": "public",
165+
"kind": "keyword"
166+
}
167+
]
168+
},
169+
{
170+
"name": "readonly",
171+
"kind": "keyword",
172+
"kindModifiers": "",
173+
"sortText": "15",
174+
"displayParts": [
175+
{
176+
"text": "readonly",
177+
"kind": "keyword"
178+
}
179+
]
180+
},
181+
{
182+
"name": "set",
183+
"kind": "keyword",
184+
"kindModifiers": "",
185+
"sortText": "15",
186+
"displayParts": [
187+
{
188+
"text": "set",
189+
"kind": "keyword"
190+
}
191+
]
192+
},
193+
{
194+
"name": "static",
195+
"kind": "keyword",
196+
"kindModifiers": "",
197+
"sortText": "15",
198+
"displayParts": [
199+
{
200+
"text": "static",
201+
"kind": "keyword"
202+
}
203+
]
204+
},
205+
{
206+
"name": "pipe",
207+
"kind": "method",
208+
"kindModifiers": "",
209+
"sortText": "17",
210+
"insertText": "pipe(): Observable<any>;\npipe<A>(): Observable<A>;\npipe<A, B>(): Observable<B>;\npipe<A, B, C>(): Observable<C>;\npipe<A, B, C, D>(): Observable<D>;\npipe<A, B, C, D, E>(): Observable<E>;\npipe<A, B, C, D, E, F>(): Observable<F>;\npipe<A, B, C, D, E, F, G>(): Observable<G>;\npipe<A, B, C, D, E, F, G, H>(): Observable<H>;\npipe<A, B, C, D, E, F, G, H, I>(): Observable<I>;\npipe<A, B, C, D, E, F, G, H, I>(): Observable<unknown>;\npipe(): Observable<any> | Observable<A> | Observable<B> | Observable<C> | Observable<D> | Observable<E> | Observable<F> | Observable<G> | Observable<H> | Observable<I> | Observable<unknown> {\n $0\n}",
211+
"isSnippet": true,
212+
"displayParts": [
213+
{
214+
"text": "(",
215+
"kind": "punctuation"
216+
},
217+
{
218+
"text": "method",
219+
"kind": "text"
220+
},
221+
{
222+
"text": ")",
223+
"kind": "punctuation"
224+
},
225+
{
226+
"text": " ",
227+
"kind": "space"
228+
},
229+
{
230+
"text": "Observable",
231+
"kind": "className"
232+
},
233+
{
234+
"text": "<",
235+
"kind": "punctuation"
236+
},
237+
{
238+
"text": "any",
239+
"kind": "keyword"
240+
},
241+
{
242+
"text": ">",
243+
"kind": "punctuation"
244+
},
245+
{
246+
"text": ".",
247+
"kind": "punctuation"
248+
},
249+
{
250+
"text": "pipe",
251+
"kind": "methodName"
252+
},
253+
{
254+
"text": "(",
255+
"kind": "punctuation"
256+
},
257+
{
258+
"text": ")",
259+
"kind": "punctuation"
260+
},
261+
{
262+
"text": ":",
263+
"kind": "punctuation"
264+
},
265+
{
266+
"text": " ",
267+
"kind": "space"
268+
},
269+
{
270+
"text": "Observable",
271+
"kind": "className"
272+
},
273+
{
274+
"text": "<",
275+
"kind": "punctuation"
276+
},
277+
{
278+
"text": "any",
279+
"kind": "keyword"
280+
},
281+
{
282+
"text": ">",
283+
"kind": "punctuation"
284+
},
285+
{
286+
"text": " ",
287+
"kind": "space"
288+
},
289+
{
290+
"text": "(",
291+
"kind": "punctuation"
292+
},
293+
{
294+
"text": "+",
295+
"kind": "operator"
296+
},
297+
{
298+
"text": "10",
299+
"kind": "numericLiteral"
300+
},
301+
{
302+
"text": " ",
303+
"kind": "space"
304+
},
305+
{
306+
"text": "overloads",
307+
"kind": "text"
308+
},
309+
{
310+
"text": ")",
311+
"kind": "punctuation"
312+
}
313+
],
314+
"documentation": []
315+
}
316+
]
317+
}
318+
}
319+
]
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
/// <reference path="fourslash.ts" />
2+
3+
// @filename: /foo.ts
4+
////export class Observable<T> {
5+
//// pipe(): Observable<T>;
6+
//// pipe<A>(): Observable<A>;
7+
//// pipe<A, B>(): Observable<B>;
8+
//// pipe<A, B, C>(): Observable<C>;
9+
//// pipe<A, B, C, D>(): Observable<D>;
10+
//// pipe<A, B, C, D, E>(): Observable<E>;
11+
//// pipe<A, B, C, D, E, F>(): Observable<F>;
12+
//// pipe<A, B, C, D, E, F, G>(): Observable<G>;
13+
//// pipe<A, B, C, D, E, F, G, H>(): Observable<H>;
14+
//// pipe<A, B, C, D, E, F, G, H, I>(): Observable<I>;
15+
//// pipe<A, B, C, D, E, F, G, H, I>(): Observable<unknown>;
16+
////}
17+
////export class Foo extends Observable<any> {
18+
//// /**/
19+
////}
20+
21+
verify.baselineCompletions({
22+
includeCompletionsWithInsertText: true,
23+
includeCompletionsWithSnippetText: true,
24+
includeCompletionsWithClassMemberSnippets: true,
25+
});

0 commit comments

Comments
 (0)