mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-10 21:07:52 -05:00
A parameter not declared as a rest parameter is not one (#18825)
This commit is contained in:
@@ -20298,7 +20298,7 @@ namespace ts {
|
||||
|
||||
function checkCollisionWithArgumentsInGeneratedCode(node: SignatureDeclaration) {
|
||||
// no rest parameters \ declaration context \ overload - no codegen impact
|
||||
if (!hasDeclaredRestParameter(node) || isInAmbientContext(node) || nodeIsMissing((<FunctionLikeDeclaration>node).body)) {
|
||||
if (!hasRestParameter(node) || isInAmbientContext(node) || nodeIsMissing((<FunctionLikeDeclaration>node).body)) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -1604,26 +1604,12 @@ namespace ts {
|
||||
}
|
||||
|
||||
export function hasRestParameter(s: SignatureDeclaration): boolean {
|
||||
return isRestParameter(lastOrUndefined(s.parameters));
|
||||
const last = lastOrUndefined(s.parameters);
|
||||
return last && isRestParameter(last);
|
||||
}
|
||||
|
||||
export function hasDeclaredRestParameter(s: SignatureDeclaration): boolean {
|
||||
return isDeclaredRestParam(lastOrUndefined(s.parameters));
|
||||
}
|
||||
|
||||
export function isRestParameter(node: ParameterDeclaration) {
|
||||
if (isInJavaScriptFile(node)) {
|
||||
if (node.type && node.type.kind === SyntaxKind.JSDocVariadicType ||
|
||||
forEach(getJSDocParameterTags(node),
|
||||
t => t.typeExpression && t.typeExpression.type.kind === SyntaxKind.JSDocVariadicType)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return isDeclaredRestParam(node);
|
||||
}
|
||||
|
||||
export function isDeclaredRestParam(node: ParameterDeclaration) {
|
||||
return node && node.dotDotDotToken !== undefined;
|
||||
export function isRestParameter(node: ParameterDeclaration): boolean {
|
||||
return node.dotDotDotToken !== undefined;
|
||||
}
|
||||
|
||||
export const enum AssignmentKind {
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
* @returns {*} Returns the result of `func`.
|
||||
*/
|
||||
function apply(func, thisArg, args) {
|
||||
>apply : (func: Function, thisArg: any, ...args: any[]) => any
|
||||
>apply : (func: Function, thisArg: any, args: any[]) => any
|
||||
>func : Function
|
||||
>thisArg : any
|
||||
>args : any[]
|
||||
@@ -84,5 +84,5 @@ function apply(func, thisArg, args) {
|
||||
}
|
||||
|
||||
export default apply;
|
||||
>apply : (func: Function, thisArg: any, ...args: any[]) => any
|
||||
>apply : (func: Function, thisArg: any, args: any[]) => any
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
* @param {...number?[]!} k - (number[] | null)[]
|
||||
*/
|
||||
function f(x, y, z, a, b, c, d, e, f, g, h, i, j, k) {
|
||||
>f : (x: number[], y: number[], z: number[], a: (number | null)[], b: number[] | null, c: number[] | null, d: number[] | null, ...e: (number | null)[], f: number[] | null, g: number[] | null, h: number[] | null, i: number[][], j: number[][] | null, k: (number[] | null)[]) => void
|
||||
>f : (x: number[], y: number[], z: number[], a: (number | null)[], b: number[] | null, c: number[] | null, d: number[] | null, e: (number | null)[], f: number[] | null, g: number[] | null, h: number[] | null, i: number[][], j: number[][] | null, k: (number[] | null)[]) => void
|
||||
>x : number[]
|
||||
>y : number[]
|
||||
>z : number[]
|
||||
|
||||
Reference in New Issue
Block a user