mirror of
https://github.com/microsoft/TypeScript.git
synced 2025-11-18 17:21:48 +00:00
report error for duplicate @type declaration (#38340)
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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}
|
||||
*/
|
||||
Reference in New Issue
Block a user