File tree Expand file tree Collapse file tree 2 files changed +32
-3
lines changed
tests/cases/conformance/jsdoc Expand file tree Collapse file tree 2 files changed +32
-3
lines changed Original file line number Diff line number Diff line change @@ -12760,8 +12760,6 @@ namespace ts {
1276012760 }
1276112761
1276212762 function getSignatureFromDeclaration(declaration: SignatureDeclaration | JSDocSignature): Signature {
12763- const signature = getSignatureOfTypeTag(declaration);
12764- if (signature) return signature;
1276512763 const links = getNodeLinks(declaration);
1276612764 if (!links.resolvedSignature) {
1276712765 const parameters: Symbol[] = [];
@@ -12941,7 +12939,15 @@ namespace ts {
1294112939 continue;
1294212940 }
1294312941 }
12944- result.push(getSignatureFromDeclaration(decl));
12942+ // If this is a function or method declaration, get the accurate minArgumentCount from the type tag, if present.
12943+ // If this is a variable or property declaration, apply the type tag to the target
12944+ // (getTypeForVariableLikeDeclaration()), not to the initializer.
12945+ result.push(
12946+ (!isFunctionExpressionOrArrowFunction(decl) &&
12947+ !isObjectLiteralMethod(decl) &&
12948+ getSignatureOfTypeTag(decl)) ||
12949+ getSignatureFromDeclaration(decl)
12950+ );
1294512951 }
1294612952 return result;
1294712953 }
Original file line number Diff line number Diff line change @@ -21,3 +21,26 @@ function add2(a, b) { return a + b; }
2121// TODO: Should be an error since signature doesn't match.
2222/** @type {(a: number, b: number, c: number) => number } */
2323function add3 ( a , b ) { return a + b ; }
24+
25+ // Confirm initializers are compatible.
26+ // They can't have more parameters than the target.
27+
28+ /** @type {() => void } */
29+ function func ( more ) { }
30+
31+ /** @type {() => void } */
32+ const variable = function ( more ) { } ;
33+
34+ /** @type {() => void } */
35+ const arrow = ( more ) => { } ;
36+
37+ ( {
38+ /** @type {() => void } */
39+ method ( more ) { } ,
40+
41+ /** @type {() => void } */
42+ prop : function ( more ) { } ,
43+
44+ /** @type {() => void } */
45+ arrow : ( more ) => { } ,
46+ } ) ;
You can’t perform that action at this time.
0 commit comments