mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-04-17 01:49:41 -05:00
fix(51112): skip checking binding parameters for functions that contains arguments (#51258)
This commit is contained in:
@@ -40289,9 +40289,10 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
|
||||
|
||||
const containsArguments = containsArgumentsReference(node);
|
||||
if (containsArguments) {
|
||||
const lastJSDocParam = lastOrUndefined(jsdocParameters);
|
||||
const lastJSDocParamIndex = jsdocParameters.length - 1;
|
||||
const lastJSDocParam = jsdocParameters[lastJSDocParamIndex];
|
||||
if (isJs && lastJSDocParam && isIdentifier(lastJSDocParam.name) && lastJSDocParam.typeExpression &&
|
||||
lastJSDocParam.typeExpression.type && !parameters.has(lastJSDocParam.name.escapedText) && !isArrayType(getTypeFromTypeNode(lastJSDocParam.typeExpression.type))) {
|
||||
lastJSDocParam.typeExpression.type && !parameters.has(lastJSDocParam.name.escapedText) && !excludedParameters.has(lastJSDocParamIndex) && !isArrayType(getTypeFromTypeNode(lastJSDocParam.typeExpression.type))) {
|
||||
error(lastJSDocParam.name, Diagnostics.JSDoc_param_tag_has_name_0_but_there_is_no_parameter_with_that_name_It_would_match_arguments_if_it_had_an_array_type, idText(lastJSDocParam.name));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
tests/cases/conformance/jsdoc/0.js(61,19): error TS2339: Property 'a' does not exist on type 'String'.
|
||||
tests/cases/conformance/jsdoc/0.js(61,22): error TS2339: Property 'b' does not exist on type 'String'.
|
||||
tests/cases/conformance/jsdoc/0.js(63,20): error TS8024: JSDoc '@param' tag has name 'y', but there is no parameter with that name.
|
||||
tests/cases/conformance/jsdoc/0.js(68,19): error TS2339: Property 'a' does not exist on type 'String'.
|
||||
tests/cases/conformance/jsdoc/0.js(68,22): error TS2339: Property 'b' does not exist on type 'String'.
|
||||
tests/cases/conformance/jsdoc/0.js(70,20): error TS8024: JSDoc '@param' tag has name 'y', but there is no parameter with that name.
|
||||
|
||||
|
||||
==== tests/cases/conformance/jsdoc/0.js (3 errors) ====
|
||||
@@ -58,6 +58,13 @@ tests/cases/conformance/jsdoc/0.js(63,20): error TS8024: JSDoc '@param' tag has
|
||||
*/
|
||||
function good8({a, b}) {}
|
||||
|
||||
/**
|
||||
* @param {{ a: string }} argument
|
||||
*/
|
||||
function good9({ a }) {
|
||||
console.log(arguments, a);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {object} obj - this type gets ignored
|
||||
* @param {string} obj.a
|
||||
|
||||
@@ -93,6 +93,21 @@ function good8({a, b}) {}
|
||||
>a : Symbol(a, Decl(0.js, 52, 16))
|
||||
>b : Symbol(b, Decl(0.js, 52, 18))
|
||||
|
||||
/**
|
||||
* @param {{ a: string }} argument
|
||||
*/
|
||||
function good9({ a }) {
|
||||
>good9 : Symbol(good9, Decl(0.js, 52, 25))
|
||||
>a : Symbol(a, Decl(0.js, 57, 16))
|
||||
|
||||
console.log(arguments, a);
|
||||
>console.log : Symbol(Console.log, Decl(lib.dom.d.ts, --, --))
|
||||
>console : Symbol(console, Decl(lib.dom.d.ts, --, --))
|
||||
>log : Symbol(Console.log, Decl(lib.dom.d.ts, --, --))
|
||||
>arguments : Symbol(arguments)
|
||||
>a : Symbol(a, Decl(0.js, 57, 16))
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {object} obj - this type gets ignored
|
||||
* @param {string} obj.a
|
||||
@@ -100,18 +115,18 @@ function good8({a, b}) {}
|
||||
* @param {string} x
|
||||
*/
|
||||
function bad1(x, {a, b}) {}
|
||||
>bad1 : Symbol(bad1, Decl(0.js, 52, 25))
|
||||
>x : Symbol(x, Decl(0.js, 60, 14))
|
||||
>a : Symbol(a, Decl(0.js, 60, 18))
|
||||
>b : Symbol(b, Decl(0.js, 60, 20))
|
||||
>bad1 : Symbol(bad1, Decl(0.js, 59, 1))
|
||||
>x : Symbol(x, Decl(0.js, 67, 14))
|
||||
>a : Symbol(a, Decl(0.js, 67, 18))
|
||||
>b : Symbol(b, Decl(0.js, 67, 20))
|
||||
|
||||
/**
|
||||
* @param {string} y - here, y's type gets ignored but obj's is fine
|
||||
* @param {{a: string, b: string}} obj
|
||||
*/
|
||||
function bad2(x, {a, b}) {}
|
||||
>bad2 : Symbol(bad2, Decl(0.js, 60, 27))
|
||||
>x : Symbol(x, Decl(0.js, 65, 14))
|
||||
>a : Symbol(a, Decl(0.js, 65, 18))
|
||||
>b : Symbol(b, Decl(0.js, 65, 20))
|
||||
>bad2 : Symbol(bad2, Decl(0.js, 67, 27))
|
||||
>x : Symbol(x, Decl(0.js, 72, 14))
|
||||
>a : Symbol(a, Decl(0.js, 72, 18))
|
||||
>b : Symbol(b, Decl(0.js, 72, 20))
|
||||
|
||||
|
||||
@@ -93,6 +93,22 @@ function good8({a, b}) {}
|
||||
>a : string
|
||||
>b : string
|
||||
|
||||
/**
|
||||
* @param {{ a: string }} argument
|
||||
*/
|
||||
function good9({ a }) {
|
||||
>good9 : ({ a }: { a: string;}, ...args: any[]) => void
|
||||
>a : string
|
||||
|
||||
console.log(arguments, a);
|
||||
>console.log(arguments, a) : void
|
||||
>console.log : (...data: any[]) => void
|
||||
>console : Console
|
||||
>log : (...data: any[]) => void
|
||||
>arguments : IArguments
|
||||
>a : string
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {object} obj - this type gets ignored
|
||||
* @param {string} obj.a
|
||||
|
||||
@@ -57,6 +57,13 @@ function good7(x, {a, b}, y) {}
|
||||
*/
|
||||
function good8({a, b}) {}
|
||||
|
||||
/**
|
||||
* @param {{ a: string }} argument
|
||||
*/
|
||||
function good9({ a }) {
|
||||
console.log(arguments, a);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {object} obj - this type gets ignored
|
||||
* @param {string} obj.a
|
||||
|
||||
Reference in New Issue
Block a user