report error for duplicate @type declaration (#38340)

This commit is contained in:
Wenqi
2020-05-11 12:47:49 -07:00
committed by GitHub
parent 738b6b5b68
commit 1b7b3eb0f7
6 changed files with 52 additions and 0 deletions
+8
View File
@@ -4911,6 +4911,14 @@
"category": "Error",
"code": 8032
},
"A JSDoc '@typedef' comment may not contain multiple '@type' tags.": {
"category": "Error",
"code": 8033
},
"The tag was first specified here.": {
"category": "Error",
"code": 8034
},
"Only identifiers/qualified-names with optional type arguments are currently supported in a class 'extends' clause.": {
"category": "Error",
"code": 9002
+8
View File
@@ -7483,6 +7483,14 @@ namespace ts {
}
if (child.kind === SyntaxKind.JSDocTypeTag) {
if (childTypeTag) {
parseErrorAtCurrentToken(Diagnostics.A_JSDoc_typedef_comment_may_not_contain_multiple_type_tags);
const lastError = lastOrUndefined(parseDiagnostics);
if (lastError) {
addRelatedInfo(
lastError,
createDiagnosticForNode(sourceFile, Diagnostics.The_tag_was_first_specified_here)
);
}
break;
}
else {
@@ -0,0 +1,13 @@
tests/cases/conformance/jsdoc/typedefDuplicateTypeDeclaration.js(4,16): error TS8033: A JSDoc '@typedef' comment may not contain multiple '@type' tags.
==== tests/cases/conformance/jsdoc/typedefDuplicateTypeDeclaration.js (1 errors) ====
/**
* @typedef Name
* @type {string}
* @type {Oops}
*/
!!! error TS8033: A JSDoc '@typedef' comment may not contain multiple '@type' tags.
!!! related TS8034 tests/cases/conformance/jsdoc/typedefDuplicateTypeDeclaration.js:1:1: The tag was first specified here.
@@ -0,0 +1,7 @@
=== tests/cases/conformance/jsdoc/typedefDuplicateTypeDeclaration.js ===
/**
No type information for this code. * @typedef Name
No type information for this code. * @type {string}
No type information for this code. * @type {Oops}
No type information for this code. */
No type information for this code.
@@ -0,0 +1,7 @@
=== tests/cases/conformance/jsdoc/typedefDuplicateTypeDeclaration.js ===
/**
No type information for this code. * @typedef Name
No type information for this code. * @type {string}
No type information for this code. * @type {Oops}
No type information for this code. */
No type information for this code.
@@ -0,0 +1,9 @@
// @allowJS: true
// @checkJS: true
// @noEmit: true
// @Filename: typedefDuplicateTypeDeclaration.js
/**
* @typedef Name
* @type {string}
* @type {Oops}
*/