Fix string completions depending on contextual signatures (#52717)

This commit is contained in:
Mateusz Burzyński 2023-03-08 01:42:16 +01:00 committed by GitHub
parent f555ad73db
commit 6e4f0a430e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 44 additions and 1 deletions

View File

@ -37545,7 +37545,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));

View File

@ -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"`] })
verify.completions({ marker: "2", exact: [`EVENT`] })