Skip to content

Fix string completions depending on contextual signatures #52717

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/compiler/checker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37307,7 +37307,9 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
return nullWideningType;
case SyntaxKind.NoSubstitutionTemplateLiteral:
case SyntaxKind.StringLiteral:
return getFreshTypeOfLiteralType(getStringLiteralType((node as StringLiteralLike).text));
return hasSkipDirectInferenceFlag(node) ?
anyType :
getFreshTypeOfLiteralType(getStringLiteralType((node as StringLiteralLike).text));
case SyntaxKind.NumericLiteral:
checkGrammarNumericLiteral(node as NumericLiteral);
return getFreshTypeOfLiteralType(getNumberLiteralType(+(node as NumericLiteral).text));
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/// <reference path="fourslash.ts" />
// @strict: true
////
//// type ActorRef<TEvent extends { type: string }> = {
//// send: (ev: TEvent) => void
//// }
////
//// type Action<TContext> = {
//// (ctx: TContext): void
//// }
////
//// type Config<TContext> = {
//// entry: Action<TContext>
//// }
////
//// declare function createMachine<TContext>(config: Config<TContext>): void
////
//// type EventFrom<T> = T extends ActorRef<infer TEvent> ? TEvent : never
////
//// declare function sendTo<
//// TContext,
//// TActor extends ActorRef<any>
//// >(
//// actor: ((ctx: TContext) => TActor),
//// event: EventFrom<TActor>
//// ): Action<TContext>
////
//// createMachine<{
//// child: ActorRef<{ type: "EVENT" }>;
//// }>({
//// entry: sendTo((ctx) => ctx.child, { type: /*1*/ }),
//// });
////
//// createMachine<{
//// child: ActorRef<{ type: "EVENT" }>;
//// }>({
//// entry: sendTo((ctx) => ctx.child, { type: "/*2*/" }),
//// });

verify.completions({ marker: "1", includes: [`"EVENT"`] })
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this one was already working since the omitted node~ was already producing { type: any } and thus didn't fail the applicability check, whereas when requesting the string completion the type was { type: '' } and it was failing the check and thus failing to provide the completions

verify.completions({ marker: "2", exact: [`EVENT`] })