Skip to content

Commit 6e4f0a4

Browse files
authored
Fix string completions depending on contextual signatures (#52717)
1 parent f555ad7 commit 6e4f0a4

File tree

2 files changed

+44
-1
lines changed

2 files changed

+44
-1
lines changed

src/compiler/checker.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37545,7 +37545,9 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
3754537545
return nullWideningType;
3754637546
case SyntaxKind.NoSubstitutionTemplateLiteral:
3754737547
case SyntaxKind.StringLiteral:
37548-
return getFreshTypeOfLiteralType(getStringLiteralType((node as StringLiteralLike).text));
37548+
return hasSkipDirectInferenceFlag(node) ?
37549+
anyType :
37550+
getFreshTypeOfLiteralType(getStringLiteralType((node as StringLiteralLike).text));
3754937551
case SyntaxKind.NumericLiteral:
3755037552
checkGrammarNumericLiteral(node as NumericLiteral);
3755137553
return getFreshTypeOfLiteralType(getNumberLiteralType(+(node as NumericLiteral).text));
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
/// <reference path="fourslash.ts" />
2+
// @strict: true
3+
////
4+
//// type ActorRef<TEvent extends { type: string }> = {
5+
//// send: (ev: TEvent) => void
6+
//// }
7+
////
8+
//// type Action<TContext> = {
9+
//// (ctx: TContext): void
10+
//// }
11+
////
12+
//// type Config<TContext> = {
13+
//// entry: Action<TContext>
14+
//// }
15+
////
16+
//// declare function createMachine<TContext>(config: Config<TContext>): void
17+
////
18+
//// type EventFrom<T> = T extends ActorRef<infer TEvent> ? TEvent : never
19+
////
20+
//// declare function sendTo<
21+
//// TContext,
22+
//// TActor extends ActorRef<any>
23+
//// >(
24+
//// actor: ((ctx: TContext) => TActor),
25+
//// event: EventFrom<TActor>
26+
//// ): Action<TContext>
27+
////
28+
//// createMachine<{
29+
//// child: ActorRef<{ type: "EVENT" }>;
30+
//// }>({
31+
//// entry: sendTo((ctx) => ctx.child, { type: /*1*/ }),
32+
//// });
33+
////
34+
//// createMachine<{
35+
//// child: ActorRef<{ type: "EVENT" }>;
36+
//// }>({
37+
//// entry: sendTo((ctx) => ctx.child, { type: "/*2*/" }),
38+
//// });
39+
40+
verify.completions({ marker: "1", includes: [`"EVENT"`] })
41+
verify.completions({ marker: "2", exact: [`EVENT`] })

0 commit comments

Comments
 (0)