isOptionalParameter says unused IIFE arguments are optional
Related to adding undefined, though not strictly the same, this change adds '?' to unused IIFE parameters in quick info.
This commit is contained in:
parent
e96b17b4f1
commit
01a9e4f9be
3 changed files with 16 additions and 5 deletions
|
@ -5145,6 +5145,12 @@ namespace ts {
|
|||
Debug.assert(parameterIndex >= 0);
|
||||
return parameterIndex >= signature.minArgumentCount;
|
||||
}
|
||||
const iife = getImmediatelyInvokedFunctionExpression(node.parent);
|
||||
if (iife) {
|
||||
return !node.type &&
|
||||
!node.dotDotDotToken &&
|
||||
indexOf((node.parent as SignatureDeclaration).parameters, node) >= iife.arguments.length;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
@ -14026,7 +14032,7 @@ namespace ts {
|
|||
return getTypeOfSymbol(symbol);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function getTypeAtPosition(signature: Signature, pos: number): Type {
|
||||
return signature.hasRestParameter ?
|
||||
pos < signature.parameters.length - 1 ? getTypeOfSymbol(signature.parameters[pos]) : getRestTypeOfSignature(signature) :
|
||||
|
|
|
@ -253,8 +253,8 @@ let eleven = (o => o.a(11))({ a: function(n) { return n; } });
|
|||
// missing arguments
|
||||
(function(x, undefined) { return x; })(42);
|
||||
>(function(x, undefined) { return x; })(42) : number
|
||||
>(function(x, undefined) { return x; }) : (x: number, undefined: any) => number
|
||||
>function(x, undefined) { return x; } : (x: number, undefined: any) => number
|
||||
>(function(x, undefined) { return x; }) : (x: number, undefined?: any) => number
|
||||
>function(x, undefined) { return x; } : (x: number, undefined?: any) => number
|
||||
>x : number
|
||||
>undefined : any
|
||||
>x : number
|
||||
|
@ -262,8 +262,8 @@ let eleven = (o => o.a(11))({ a: function(n) { return n; } });
|
|||
|
||||
((x, y, z) => 42)();
|
||||
>((x, y, z) => 42)() : number
|
||||
>((x, y, z) => 42) : (x: any, y: any, z: any) => number
|
||||
>(x, y, z) => 42 : (x: any, y: any, z: any) => number
|
||||
>((x, y, z) => 42) : (x?: any, y?: any, z?: any) => number
|
||||
>(x, y, z) => 42 : (x?: any, y?: any, z?: any) => number
|
||||
>x : any
|
||||
>y : any
|
||||
>z : any
|
||||
|
|
5
tests/cases/fourslash/quickInfoDisplayPartsIife.ts
Normal file
5
tests/cases/fourslash/quickInfoDisplayPartsIife.ts
Normal file
|
@ -0,0 +1,5 @@
|
|||
/// <reference path='fourslash.ts'/>
|
||||
// @strictNullChecks: true
|
||||
////var iife = (function foo/*1*/(x, y) { return x })(12);
|
||||
|
||||
verify.quickInfoAt('1', '(local function) foo(x: number, y?: undefined): number');
|
Loading…
Reference in a new issue