mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-05 08:11:30 -06:00
fix(54872): Have createUnionOfSignaturesForOverloadFailure() combine @deprecated tags properly (#54945)
This commit is contained in:
parent
405251ebd2
commit
ef0422b40f
@ -33488,7 +33488,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
|
||||
parameters.push(createCombinedSymbolFromTypes(symbols, mapDefined(candidates, candidate => tryGetTypeAtPosition(candidate, i))));
|
||||
}
|
||||
const restParameterSymbols = mapDefined(candidates, c => signatureHasRestParameter(c) ? last(c.parameters) : undefined);
|
||||
let flags = SignatureFlags.None;
|
||||
let flags = SignatureFlags.IsSignatureCandidateForOverloadFailure;
|
||||
if (restParameterSymbols.length !== 0) {
|
||||
const type = createArrayType(getUnionType(mapDefined(candidates, tryGetRestTypeOfSignature), UnionReduction.Subtype));
|
||||
parameters.push(createCombinedSymbolForOverloadFailure(restParameterSymbols, type));
|
||||
@ -34386,6 +34386,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
|
||||
}
|
||||
|
||||
function checkDeprecatedSignature(signature: Signature, node: CallLikeExpression) {
|
||||
if (signature.flags & SignatureFlags.IsSignatureCandidateForOverloadFailure) return;
|
||||
if (signature.declaration && signature.declaration.flags & NodeFlags.Deprecated) {
|
||||
const suggestionNode = getDeprecatedSuggestionNode(node);
|
||||
const name = tryGetPropertyAccessOrIdentifierToString(getInvokedExpression(node));
|
||||
|
||||
@ -6724,11 +6724,12 @@ export const enum SignatureFlags {
|
||||
IsOuterCallChain = 1 << 4, // Indicates signature comes from a CallChain that is the outermost chain of an optional expression
|
||||
IsUntypedSignatureInJSFile = 1 << 5, // Indicates signature is from a js file and has no types
|
||||
IsNonInferrable = 1 << 6, // Indicates signature comes from a non-inferrable type
|
||||
IsSignatureCandidateForOverloadFailure = 1 << 7,
|
||||
|
||||
// We do not propagate `IsInnerCallChain` or `IsOuterCallChain` to instantiated signatures, as that would result in us
|
||||
// attempting to add `| undefined` on each recursive call to `getReturnTypeOfSignature` when
|
||||
// instantiating the return type.
|
||||
PropagatingFlags = HasRestParameter | HasLiteralTypes | Abstract | IsUntypedSignatureInJSFile,
|
||||
PropagatingFlags = HasRestParameter | HasLiteralTypes | Abstract | IsUntypedSignatureInJSFile | IsSignatureCandidateForOverloadFailure,
|
||||
|
||||
CallChainFlags = IsInnerCallChain | IsOuterCallChain,
|
||||
}
|
||||
|
||||
14
tests/cases/fourslash/jsdocDeprecated_suggestion22.ts
Normal file
14
tests/cases/fourslash/jsdocDeprecated_suggestion22.ts
Normal file
@ -0,0 +1,14 @@
|
||||
/// <reference path="fourslash.ts" />
|
||||
|
||||
// @filename: /a.ts
|
||||
////const foo: {
|
||||
//// /**
|
||||
//// * @deprecated
|
||||
//// */
|
||||
//// (a: string, b: string): string;
|
||||
//// (a: string, b: number): string;
|
||||
////} = (a: string, b: string | number) => a + b;
|
||||
////
|
||||
////[|foo|](1, 1);
|
||||
|
||||
verify.getSuggestionDiagnostics([]);
|
||||
Loading…
x
Reference in New Issue
Block a user