A parameter not declared as a rest parameter is not one (#18825)

This commit is contained in:
Andy
2017-10-06 15:05:00 -07:00
committed by GitHub
parent 71f8852124
commit e821c2b6e9
4 changed files with 8 additions and 22 deletions

View File

@@ -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;
}

View File

@@ -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 {

View File

@@ -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

View File

@@ -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[]