Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(47949): Unexpected error in param jsdoc tags for methods containing arguments - 4.6 RC regression #47956

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions src/compiler/checker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13688,10 +13688,12 @@ namespace ts {
if (!type) {
symbol = resolveTypeReferenceName(node, meaning, /*ignoreErrors*/ true);
if (symbol === unknownSymbol) {
symbol = resolveTypeReferenceName(node, meaning | SymbolFlags.Value);
symbol = resolveTypeReferenceName(node, meaning | SymbolFlags.Value, /*ignoreErrors*/ !isInJSFile(node));
}
else {
resolveTypeReferenceName(node, meaning); // Resolve again to mark errors, if any
if (isInJSFile(node)) {
resolveTypeReferenceName(node, meaning); // Resolve again to mark errors, if any
}
}
type = getTypeReferenceType(node, symbol);
}
Expand Down
23 changes: 23 additions & 0 deletions tests/baselines/reference/paramTagOnFunctionUsingArguments2.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
//// [paramTagOnFunctionUsingArguments2.ts]
class Foo {
/**
* @param {foo-module.Foo} foo
*/
m(foo: unknown): void {
arguments;
}
}


//// [paramTagOnFunctionUsingArguments2.js]
var Foo = /** @class */ (function () {
function Foo() {
}
/**
* @param {foo-module.Foo} foo
*/
Foo.prototype.m = function (foo) {
arguments;
};
return Foo;
}());
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
=== tests/cases/conformance/jsdoc/paramTagOnFunctionUsingArguments2.ts ===
class Foo {
>Foo : Symbol(Foo, Decl(paramTagOnFunctionUsingArguments2.ts, 0, 0))

/**
* @param {foo-module.Foo} foo
*/
m(foo: unknown): void {
>m : Symbol(Foo.m, Decl(paramTagOnFunctionUsingArguments2.ts, 0, 11))
>foo : Symbol(foo, Decl(paramTagOnFunctionUsingArguments2.ts, 4, 4))

arguments;
>arguments : Symbol(arguments)
}
}

16 changes: 16 additions & 0 deletions tests/baselines/reference/paramTagOnFunctionUsingArguments2.types
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
=== tests/cases/conformance/jsdoc/paramTagOnFunctionUsingArguments2.ts ===
class Foo {
>Foo : Foo

/**
* @param {foo-module.Foo} foo
*/
m(foo: unknown): void {
>m : (foo: unknown) => void
>foo : unknown

arguments;
>arguments : IArguments
}
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
class Foo {
/**
* @param {foo-module.Foo} foo
*/
m(foo: unknown): void {
arguments;
}
}
15 changes: 15 additions & 0 deletions tests/cases/fourslash/jsdocParamTagOnFunctionUsingArguments.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
/// <reference path="fourslash.ts" />
// @strict: true

////class Foo {
//// /**
//// * @param {string} [|foo|]
//// */
//// m(): void {
//// arguments;
//// }
////}

verify.getSuggestionDiagnostics([
{ message: "JSDoc '@param' tag has name 'foo', but there is no parameter with that name. It would match 'arguments' if it had an array type.", code: 8029 },
])