mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-04 21:53:42 -06:00
Fix string completions depending on contextual signatures (#52717)
This commit is contained in:
parent
f555ad73db
commit
6e4f0a430e
@ -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));
|
||||
|
||||
@ -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`] })
|
||||
Loading…
x
Reference in New Issue
Block a user