Fix error message for class type in JSDoc missing type arguments (#27222)

This commit is contained in:
Andy 2018-09-19 12:57:55 -07:00 committed by GitHub
parent 80045ca2d8
commit 67d8263b30
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 44 additions and 1 deletions

View File

@ -8158,7 +8158,7 @@ namespace ts {
const isJs = isInJSFile(node);
const isJsImplicitAny = !noImplicitAny && isJs;
if (!isJsImplicitAny && (numTypeArguments < minTypeArgumentCount || numTypeArguments > typeParameters.length)) {
const missingAugmentsTag = isJs && node.parent.kind !== SyntaxKind.JSDocAugmentsTag;
const missingAugmentsTag = isJs && isExpressionWithTypeArguments(node) && !isJSDocAugmentsTag(node.parent);
const diag = minTypeArgumentCount === typeParameters.length
? missingAugmentsTag
? Diagnostics.Expected_0_type_arguments_provide_these_with_an_extends_tag

View File

@ -0,0 +1,12 @@
/a.js(4,13): error TS2314: Generic type 'C<T>' requires 1 type argument(s).
==== /a.js (1 errors) ====
/** @template T */
class C {}
/** @param {C} p */
~
!!! error TS2314: Generic type 'C<T>' requires 1 type argument(s).
function f(p) {}

View File

@ -0,0 +1,10 @@
=== /a.js ===
/** @template T */
class C {}
>C : Symbol(C, Decl(a.js, 0, 0))
/** @param {C} p */
function f(p) {}
>f : Symbol(f, Decl(a.js, 1, 10))
>p : Symbol(p, Decl(a.js, 4, 11))

View File

@ -0,0 +1,10 @@
=== /a.js ===
/** @template T */
class C {}
>C : C<T>
/** @param {C} p */
function f(p) {}
>f : (p: C<any>) => void
>p : C<any>

View File

@ -0,0 +1,11 @@
// @allowJs: true
// @checkJs: true
// @noEmit: true
// @noImplicitAny: true
// @Filename: /a.js
/** @template T */
class C {}
/** @param {C} p */
function f(p) {}