File tree 2 files changed +32
-3
lines changed
tests/cases/conformance/jsdoc 2 files changed +32
-3
lines changed Original file line number Diff line number Diff line change @@ -12760,8 +12760,6 @@ namespace ts {
12760
12760
}
12761
12761
12762
12762
function getSignatureFromDeclaration(declaration: SignatureDeclaration | JSDocSignature): Signature {
12763
- const signature = getSignatureOfTypeTag(declaration);
12764
- if (signature) return signature;
12765
12763
const links = getNodeLinks(declaration);
12766
12764
if (!links.resolvedSignature) {
12767
12765
const parameters: Symbol[] = [];
@@ -12941,7 +12939,15 @@ namespace ts {
12941
12939
continue;
12942
12940
}
12943
12941
}
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
+ );
12945
12951
}
12946
12952
return result;
12947
12953
}
Original file line number Diff line number Diff line change @@ -21,3 +21,26 @@ function add2(a, b) { return a + b; }
21
21
// TODO: Should be an error since signature doesn't match.
22
22
/** @type {(a: number, b: number, c: number) => number } */
23
23
function 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