mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-15 03:23:08 -06:00
Fixed an issue with errors not being correctly reported after completion requests in nested calls (#54658)
This commit is contained in:
parent
b1c2e8caad
commit
abf0ef8eef
@ -1828,14 +1828,19 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
|
||||
};
|
||||
|
||||
function runWithoutResolvedSignatureCaching<T>(node: Node | undefined, fn: () => T): T {
|
||||
const containingCall = findAncestor(node, isCallLikeExpression);
|
||||
const containingCallResolvedSignature = containingCall && getNodeLinks(containingCall).resolvedSignature;
|
||||
if (containingCall) {
|
||||
getNodeLinks(containingCall).resolvedSignature = undefined;
|
||||
const cachedSignatures = [];
|
||||
while (node) {
|
||||
if (isCallLikeExpression(node)) {
|
||||
const nodeLinks = getNodeLinks(node);
|
||||
const resolvedSignature = nodeLinks.resolvedSignature;
|
||||
cachedSignatures.push([nodeLinks, resolvedSignature] as const);
|
||||
nodeLinks.resolvedSignature = undefined;
|
||||
}
|
||||
node = node.parent;
|
||||
}
|
||||
const result = fn();
|
||||
if (containingCall) {
|
||||
getNodeLinks(containingCall).resolvedSignature = containingCallResolvedSignature;
|
||||
for (const [nodeLinks, resolvedSignature] of cachedSignatures) {
|
||||
nodeLinks.resolvedSignature = resolvedSignature;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -0,0 +1,32 @@
|
||||
///<reference path="fourslash.ts"/>
|
||||
// @strict: true
|
||||
////
|
||||
//// type GreetingEvent =
|
||||
//// | { type: "MORNING" }
|
||||
//// | { type: "LUNCH_TIME" }
|
||||
//// | { type: "ALOHA" };
|
||||
////
|
||||
//// interface RaiseActionObject<TEvent extends { type: string }> {
|
||||
//// type: "raise";
|
||||
//// event: TEvent;
|
||||
//// }
|
||||
////
|
||||
//// declare function raise<TEvent extends { type: string }>(
|
||||
//// ev: TEvent
|
||||
//// ): RaiseActionObject<TEvent>;
|
||||
////
|
||||
//// declare function createMachine<TEvent extends { type: string }>(config: {
|
||||
//// actions: RaiseActionObject<TEvent>;
|
||||
//// }): void;
|
||||
////
|
||||
//// createMachine<GreetingEvent>({
|
||||
//// [|/*error*/actions|]: raise({ type: "ALOHA/*1*/" }),
|
||||
//// });
|
||||
|
||||
goTo.marker("1");
|
||||
edit.insert(`x`)
|
||||
verify.completions({ exact: ["MORNING", "LUNCH_TIME", "ALOHA"] });
|
||||
verify.getSemanticDiagnostics([{
|
||||
code: 2322,
|
||||
message: `Type 'RaiseActionObject<{ type: "ALOHAx"; }>' is not assignable to type 'RaiseActionObject<GreetingEvent>'.\n Type '{ type: "ALOHAx"; }' is not assignable to type 'GreetingEvent'.\n Type '{ type: "ALOHAx"; }' is not assignable to type '{ type: "ALOHA"; }'.\n Types of property 'type' are incompatible.\n Type '"ALOHAx"' is not assignable to type '"ALOHA"'.`,
|
||||
}]);
|
||||
Loading…
x
Reference in New Issue
Block a user